|
| 1 | +name: Release - Dry Run |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ main, '+.x', beta, alpha ] |
| 6 | + |
| 7 | +permissions: {} |
| 8 | + |
| 9 | +jobs: |
| 10 | + release-dryrun: |
| 11 | + name: Release - Dry Run |
| 12 | + runs-on: ubuntu-24.04 |
| 13 | + timeout-minutes: 15 |
| 14 | + |
| 15 | + permissions: |
| 16 | + contents: write # Necessary for semantic-release to verify Git push permissions, even during a dry run. |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Harden runner |
| 20 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 21 | + with: |
| 22 | + disable-sudo-and-containers: true |
| 23 | + egress-policy: block |
| 24 | + allowed-endpoints: > |
| 25 | + github.com:443 |
| 26 | + *.github.com:443 |
| 27 | + *.githubusercontent.com:443 |
| 28 | + api.nuget.org:443 |
| 29 | + registry.npmjs.org:443 |
| 30 | +
|
| 31 | + - name: Checkout repository |
| 32 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 33 | + with: |
| 34 | + fetch-depth: 0 # Required by semantic-release |
| 35 | + # Use the pull request head ref (source branch) to ensure the dry run simulates a release for the current PR. |
| 36 | + # LIMITATION: will probably not work with pull requests from forks forbidding read accesses. |
| 37 | + ref: ${{ github.head_ref }} |
| 38 | + |
| 39 | + - name: Setup Node.js |
| 40 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 41 | + with: |
| 42 | + node-version: lts/jod |
| 43 | + cache: npm |
| 44 | + cache-dependency-path: .github/release/package-lock.json |
| 45 | + |
| 46 | + - name: Install semantic-release |
| 47 | + working-directory: .github/release/ |
| 48 | + run: npm clean-install --engine-strict |
| 49 | + |
| 50 | + - name: Simulate new feature |
| 51 | + run: | |
| 52 | + git config --local user.name 'github-actions[bot]' |
| 53 | + git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com' |
| 54 | + git commit --no-verify --allow-empty -m 'feat: simulate new feature' |
| 55 | +
|
| 56 | + - name: Release |
| 57 | + env: |
| 58 | + GITHUB_TOKEN: ${{ github.token }} |
| 59 | + working-directory: .github/release/ |
| 60 | + # Perform a dry run without publishing anything. |
| 61 | + # |
| 62 | + # Unset the `GITHUB_ACTIONS` environment variable to trick semantic-release into thinking it's not running in a CI environment, |
| 63 | + # as `--no-ci` alone is insufficient. |
| 64 | + # |
| 65 | + # Use `--branches '${{ github.head_ref }}'` to consider the PR head ref (source branch) as a release one for the dry run. |
| 66 | + run: | |
| 67 | + unset GITHUB_ACTIONS |
| 68 | + npx --no-install semantic-release --dry-run --no-ci --branches '${{ github.head_ref }}' |
0 commit comments