Migrate to changesets from custom release tooling (#5840)

- Remove custom release tooling in favor of changesets
- Add changesets for all unreleased commits
This commit is contained in:
Merlijn Vos 2025-07-24 09:24:09 +02:00 committed by GitHub
parent 0525a2c91a
commit 0c24c5aeab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 576 additions and 949 deletions

View file

@ -1,91 +0,0 @@
name: Release candidate
on:
push:
branches:
- release
env:
YARN_ENABLE_GLOBAL_CACHE: false
jobs:
prepare-release:
name: Prepare release candidate Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: release
- name: Rebase
run: |
git fetch origin HEAD --depth=1
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git rebase FETCH_HEAD
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run:
echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: corepack yarn install --immutable
env:
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
CYPRESS_INSTALL_BINARY: 0
- name: Bump candidate packages version
run: corepack yarn version apply --all --json | jq -s > releases.json
- name: Prepare changelog
run:
corepack yarn workspace @uppy-dev/release update-changelogs
releases.json | xargs git add
- name: Update CDN URLs
run:
corepack yarn workspace @uppy-dev/release update-version-URLs | xargs
git add
- name: Stage changes and remove temp files
run: |
git rm -rf .yarn/versions
git rm CHANGELOG.next.md
jq -r 'map(.cwd) | join("\n")' < releases.json | awk '{ print "git add " $0 "/package.json" }' | sh
- name: Commit
run: |
echo "Release: uppy@$(jq -r 'map(select(.ident == "uppy"))[0].newVersion' < releases.json)" > commitMessage
echo >> commitMessage
echo "This is a release candidate for the following packages:" >> commitMessage
echo >> commitMessage
jq -r 'map("- `"+.ident+"`: "+.oldVersion+" -> "+.newVersion) | join("\n") ' < releases.json >> commitMessage
git commit -n --amend --file commitMessage
- name: Open Pull Request
id: pr_opening
run: |
git push origin HEAD:release-candidate
gh api repos/${{ github.repository }}/pulls \
-F base="$(gh api /repos/${{ github.repository }} | jq -r .default_branch)" \
-F head="release-candidate" \
-F title="$(head -1 commitMessage)" \
-F body="$(git --no-pager diff HEAD^ -- CHANGELOG.md | awk '{ if( substr($0,0,1) == "+" && $1 != "+##" && $1 != "+Released:" && $1 != "+++" ) { print substr($0,2) } }')" \
--jq '.number | tostring | "pr_number="+.' >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Assign to the releaser
run:
echo '{"assignees":[${{ toJSON(github.actor) }}]}' | gh api repos/${{
github.repository }}/issues/${{ steps.pr_opening.outputs.pr_number
}}/assignees --input -
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable Release workflow
run: gh workflow enable 15329895 --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,172 +1,43 @@
name: Release
on:
pull_request_review:
types: [submitted]
name: release
env:
YARN_ENABLE_GLOBAL_CACHE: false
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Publish releases
if:
${{ github.event.review.state == 'approved' && github.event.sender.login
== github.event.pull_request.assignee.login &&
github.event.pull_request.head.ref == 'release-candidate' }}
outputs:
companionWasReleased:
${{ steps.checkIfCompanionWasReleased.outputs.version }}
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout sources
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run:
echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
# Allow yarn to make changes during release
- run: corepack yarn config set enableHardenedMode false
- run: corepack yarn --mode=update-lockfile
- name: Install dependencies
run: corepack yarn install --immutable
env:
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
CYPRESS_INSTALL_BINARY: 0
- name: Get CHANGELOG diff
run:
git --no-pager diff HEAD^ -- CHANGELOG.md | awk '{ if( substr($0,0,1)
== "+" && $1 != "+##" && $1 != "+Released:" && $1 != "+++" ) { print
substr($0,2) } }' > CHANGELOG.diff.md
- name: Copy README for `uppy` package
run: cp README.md packages/uppy/.
- name: Build before publishing
run: corepack yarn run build
- name: Hack to allow the publish of the Angular package
run: corepack yarn workspace @uppy/angular prepublishOnly
- name: Publish to the npm registry
run:
corepack yarn workspaces foreach --all --no-private npm publish
--access public --tolerate-republish
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Merge PR
id: merge
run: |
gh api -X PUT repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge \
-F merge_method="squash" \
-F commit_message="$(cat CHANGELOG.diff.md)" \
--jq 'if .merged then "sha="+.sha else error("not merged") end' >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create tags
continue-on-error: true
run: |
git --no-pager diff --name-only HEAD^ | awk '$0 ~ /^packages\/.+\/package\.json$/ { print "jq -r '"'"'\"gh api /repos/{owner}/{repo}/git/refs -f ref=\\\"refs/tags/\"+.name+\"@\"+.version+\"\\\" -f sha=${{ steps.merge.outputs.sha }}\"'"'"' < " $0 }' > createTags.sh
cat createTags.sh
sh createTags.sh | sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Uppy version number
id: uppyVersion
run:
jq -r '"version="+.version' < packages/uppy/package.json >>
$GITHUB_OUTPUT
- name: Create GitHub release
run: |
if ! gh release view uppy@${{ steps.uppyVersion.outputs.version }} > /dev/null 2>&1; then
gh release create uppy@${{ steps.uppyVersion.outputs.version }} \
-t "Uppy ${{ steps.uppyVersion.outputs.version }}" \
-F CHANGELOG.diff.md
else
echo "Release ${{ steps.uppyVersion.outputs.version }} already exists. Skipping."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload `uppy` to CDN
run: corepack yarn run uploadcdn uppy -- --force
env:
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
- name: Upload `@uppy/locales` to CDN if it was released
run: corepack yarn run uploadcdn @uppy/locales -- --force
env:
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
- name: Check if Companion was released
id: checkIfCompanionWasReleased
run:
git diff --exit-code --quiet HEAD^ --
packages/@uppy/companion/package.json || echo "version=$(jq -r
.version < packages/@uppy/companion/package.json)" >> $GITHUB_OUTPUT
- name: Remove release-candidate branch
run:
gh api -X DELETE repos/${{ github.repository
}}/git/refs/heads/release-candidate || echo "Already deleted"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Remove release branch
run:
gh api -X DELETE repos/${{ github.repository }}/git/refs/heads/release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Disable Release workflow
run: gh workflow disable 15329895 --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: In case of failure
if: ${{ failure() }}
run:
gh pr comment ${{ github.event.pull_request.number }} --body "Release
job failed, please take action."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# See also companion-deploy.yml
docker:
name: DockerHub
needs: release
if: ${{ needs.release.outputs.companionWasReleased }}
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 0
COMPOSE_DOCKER_CLI_BUILD: 0
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
- name: Build
run: corepack yarn build
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
images: transloadit/companion
tags: |
type=edge
type=semver,pattern={{version}},value=${{ needs.release.outputs.companionWasReleased }}
# set latest tag for default branch
type=raw,value=latest,enable=true
- uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
- uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
- name: Build and push
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
version: corepack yarn run version
publish: corepack yarn run release
commit: '[ci] release'
title: '[ci] release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}