mirror of
https://github.com/tabler/tabler.git
synced 2026-10-21 23:34:20 +04:00
123 lines
5.4 KiB
YAML
123 lines
5.4 KiB
YAML
name: Release
|
|
|
|
# Two lines can release (see CONTRIBUTING.md, "Releases"):
|
|
# dev the next patch of the current minor; `release:main` then merges it into `main`
|
|
# next the next minor, in changesets prerelease mode: publishes `x.y.0-next.N` under
|
|
# the npm tag `next`, without a GitHub release
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
- next
|
|
|
|
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
|
|
# A `next` prerelease is only an npm tag; the GitHub release comes with the
|
|
# final version from `dev`.
|
|
create-github-releases: ${{ github.ref_name != 'next' }}
|
|
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 the branch, so this runs right
|
|
# after it. The version branch is `changeset-release/<branch>`.
|
|
- 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 }}
|
|
BRANCH: ${{ github.ref_name }}
|
|
run: |
|
|
git fetch --depth=1 origin "changeset-release/${BRANCH}"
|
|
git checkout --force --detach "origin/changeset-release/${BRANCH}"
|
|
version=$(node -p "require('./core/package.json').version")
|
|
if [ "${BRANCH}" = "next" ]; then
|
|
what="publishes \`@tabler/core@${version}\` to npm under the \`next\` tag"
|
|
else
|
|
what="publishes \`@tabler/core@${version}\` to npm and creates the GitHub release"
|
|
fi
|
|
{
|
|
echo "Merging this pull request ${what}. It is regenerated on every push to \`${BRANCH}\`."
|
|
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.
|
|
# Not on `next`: a prerelease has no GitHub release.
|
|
- name: Attach the preview zip to the GitHub release
|
|
if: steps.changesets.outputs.published == 'true' && github.ref_name != 'next'
|
|
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' && github.ref_name != 'next'
|
|
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"
|