diff --git a/.github/workflows/release-preview.yml b/.github/workflows/release-preview.yml new file mode 100644 index 00000000..7013a21a --- /dev/null +++ b/.github/workflows/release-preview.yml @@ -0,0 +1,36 @@ +name: Release Preview +"on": + pull_request: + types: + - opened + - synchronize +permissions: + contents: read # for checkout +jobs: + release-preview: + permissions: + issues: read # to be able to comment on released issues + pull-requests: read # to be able to comment on released pull requests + name: release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 # Required by semantic-release + # Use the pull request head ref (source branch) to ensure the dry run simulates a release for the current PR. + # LIMITATION: will probably not work with pull requests from forks forbidding read accesses. + ref: ${{ github.head_ref }} + - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + with: + cache: npm + node-version: lts/* + - run: npm ci + # Perform a dry run without publishing anything. + # + # Unset the `GITHUB_ACTIONS` environment variable to trick semantic-release into thinking it's not running in a CI environment, + # as `--no-ci` alone is insufficient. + # + # Use `--branches "${GITHUB_HEAD_REF}"` to consider the PR head ref (source branch) as a release one for the dry run. + - run: | + unset GITHUB_ACTIONS + npx --no-install semantic-release --dry-run --no-ci --branches "${GITHUB_HEAD_REF}" \ No newline at end of file