mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-23 10:33:24 +01:00
2b7ed1316d
Currently our release process is kicked off whenever a PR is merged and there are no changesets within the `.changeset` directory. Typically this happens when we intend to publish a release, just after we merge a "Version Packages" PR which removes the changesets and adds the entries to our changelog. However, this also means that merging any PR without user-facing changes during the period after we've made a release will trigger another release (which luckily fails because the created tag already exists on the remote. See #184). This change avoids that scenario by fetching tags when checking out the repo. Now when `npx changeset tag` runs, it will see that the tag already exists and skip creating it (`🦋 Skipping tag (already exists): v3.3.2`). The `git push --tags` step will no longer throw an error ("Everything up-to-date"). And lastly, the publish step won't get triggered because the output from `npx changeset tag` doesn't contain the string `"New tag:"`. The action should just finish successfully with nothing to left do. Fixes #184
55 lines
1.3 KiB
YAML
55 lines
1.3 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
jobs:
|
|
release:
|
|
if: ${{ github.repository_owner == 'cloudflare' }}
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
pull-requests: write
|
|
issues: read
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: "latest"
|
|
cache: "npm"
|
|
|
|
- name: Install modules
|
|
run: npm ci
|
|
|
|
- name: Create Version PR
|
|
id: changesets
|
|
uses: changesets/action@v1
|
|
with:
|
|
createGithubReleases: true
|
|
publish: npx changeset tag
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build action
|
|
if: steps.changesets.outputs.published == 'true'
|
|
run: npm run build
|
|
|
|
- name: Push dist-tags
|
|
if: steps.changesets.outputs.published == 'true'
|
|
uses: JasonEtco/build-and-tag-action@v2
|
|
with:
|
|
tag_name: v${{ fromJSON(steps.changesets.outputs.publishedPackages)[0].version }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|