Files

107 lines
4.5 KiB
YAML

name: Release
on:
push:
branches:
- dev
permissions:
contents: read
pull-requests: write
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # to create release
issues: write # to post issue comments
pull-requests: write # to create pull request
id-token: write # for npm trusted publishing (OIDC)
steps:
- name: Checkout Repo
uses: actions/checkout@v7
- name: Set up the workspace
uses: ./.github/actions/setup
with:
turbo-cache: 'false'
- name: Update npm # trusted publishing requires npm >= 11.5.1
run: npm install -g npm@11.19.1
- name: Build
run: pnpm run build
# The last gate before npm: nothing the previous release shipped may be
# missing, unless compat-baseline.txt marks it as accepted. It runs here and
# not only on the versions pull request, because workflows on a pull request
# opened by the bot wait for a manual approval and may never run. On the
# push that publishes, the local version is not on npm yet, so the check
# compares with `latest`, which is the release users update from.
- name: Check backward compatibility
run: pnpm run check:compat --strict
- name: Create release Pull Request or publish to NPM
id: changesets
uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2
with:
version-script: pnpm run version
publish-script: pnpm run publish
commit-message: "chore: update versions"
pr-title: "chore: update versions"
# Push through git instead of the GitHub API: the API mode force-updates
# changeset-release/dev via a short-lived changesets-ghcommit-temp/* branch,
# and every one of those branches triggered a Vercel build.
push-with-git-cli: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# `changesets/action` fills the version pull request with one section per
# package (`## @tabler/core@1.5.1`, …), so a changeset that touches several
# packages shows up several times. Replace that body with the same notes the
# GitHub release gets: the intro from `.github/release-notes/<version>.md`
# and the changes grouped as core / demo / docs, each listed once. The
# action rewrites the body on every push to dev, so this runs right after it.
- name: Write the release notes into the version pull request
if: steps.changesets.outputs.pr-number != ''
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.changesets.outputs.pr-number }}
run: |
git fetch --depth=1 origin changeset-release/dev
git checkout --force --detach origin/changeset-release/dev
version=$(node -p "require('./core/package.json').version")
{
echo "Merging this pull request publishes \`@tabler/core@${version}\` to npm and creates the GitHub release. It is regenerated on every push to \`dev\`."
echo
pnpm run --silent release-notes
} > "${RUNNER_TEMP}/pr-body.md"
gh pr edit "${PR_NUMBER}" --body-file "${RUNNER_TEMP}/pr-body.md"
# `pnpm run build` above zipped preview/dist into packages-zip/; attach it to
# the GitHub release that changesets/action just created for @tabler/core.
- name: Attach the preview zip to the GitHub release
if: steps.changesets.outputs.published == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(node -p "require('./core/package.json').version")
gh release upload "@tabler/core@${version}" "packages-zip/tabler-${version}.zip" --clobber
# `changesets/action` names the release `@tabler/core@1.5.0` and fills it with
# the raw changelog entry. Rename it to `Tabler v1.5.0` and replace the body with
# the intro from `.github/release-notes/<version>.md` followed by the changes
# grouped per package.
- name: Write the release notes
if: steps.changesets.outputs.published == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(node -p "require('./core/package.json').version")
pnpm run release-notes "${RUNNER_TEMP}/release-body.md"
gh release edit "@tabler/core@${version}" --title "Tabler v${version}" --notes-file "${RUNNER_TEMP}/release-body.md"