You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
4.7 KiB
124 lines
4.7 KiB
name: Release
|
|
|
|
# On every push to `main` Changesets opens (or updates) the "Version Packages"
|
|
# pull request. Merging it publishes the packages and creates the GitHub release.
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
release:
|
|
if: github.repository == 'tabler/tabler-icons'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Use Node.js 22
|
|
uses: actions/setup-node@v7
|
|
with:
|
|
node-version: 22
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
# Packages are published with npm trusted publishing (OIDC), which needs
|
|
# npm 11.5.1 or newer. Node.js 22 ships with npm 10.
|
|
- name: Update npm
|
|
run: npm install -g npm@11
|
|
|
|
- uses: pnpm/action-setup@v6
|
|
name: Install pnpm
|
|
|
|
# Preview image of the new icons and the PNG/PDF/EPS packages
|
|
- name: Install rsvg-convert
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends librsvg2-bin
|
|
|
|
- name: Get pnpm store directory
|
|
shell: bash
|
|
run: |
|
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
|
|
- uses: actions/cache@v6
|
|
name: Setup pnpm cache
|
|
with:
|
|
path: ${{ env.STORE_PATH }}
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-store-
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
# Icons are added without changesets. Generating the changeset for the
|
|
# unreleased ones before the action runs makes any new icon open (or
|
|
# update) the release pull request as a minor release.
|
|
- name: Add changeset for new icons
|
|
run: node ./.build/release-changeset.mjs
|
|
|
|
- name: Create release pull request or publish
|
|
id: changesets
|
|
uses: changesets/action@v1
|
|
with:
|
|
version: pnpm run version-packages
|
|
publish: pnpm run release
|
|
title: 'Release'
|
|
commit: 'Release'
|
|
createGithubReleases: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# Changesets describes every package separately, while GitHub gets a single
|
|
# release for all of them. The description is replaced with a preview of
|
|
# that release, with the image of the new icons on top. The image is loaded
|
|
# from the commit on the release branch, the `v<version>` tag does not
|
|
# exist yet.
|
|
- name: Show the GitHub release in the release pull request
|
|
if: steps.changesets.outputs.pullRequestNumber != ''
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ steps.changesets.outputs.pullRequestNumber }}
|
|
run: |
|
|
SHA=$(gh api "repos/${GITHUB_REPOSITORY}/commits/changeset-release/main" --jq .sha)
|
|
git fetch origin changeset-release/main
|
|
git checkout --detach "$SHA"
|
|
VERSION=$(node -p "require('./packages/icons/package.json').version")
|
|
{
|
|
echo "Merging this pull request publishes all \`@tabler/icons*\` packages in version **${VERSION}** to npm and creates the following GitHub release."
|
|
echo
|
|
echo "---"
|
|
echo
|
|
node ./.build/release-notes.mjs --ref "$SHA"
|
|
} > body.md
|
|
gh pr edit "$PR_NUMBER" --body-file body.md
|
|
|
|
# The `published` output of the action stays empty with Changesets 3, which
|
|
# no longer prints the `New tag:` lines the action looks for. Without
|
|
# pending changesets the action runs the publish command, so the release is
|
|
# created whenever it does not exist yet. It is created even when the
|
|
# publish command fails (for example when npm rejects a package that was
|
|
# already staged in an earlier run), the packages that were published
|
|
# should not stay without the release.
|
|
- name: Create GitHub release
|
|
if: ${{ !cancelled() && steps.changesets.outputs.hasChangesets == 'false' }}
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
VERSION=$(node -p "require('./packages/icons/package.json').version")
|
|
if gh release view "v${VERSION}" > /dev/null 2>&1; then
|
|
echo "Release v${VERSION} already exists"
|
|
exit 0
|
|
fi
|
|
node ./.build/release-notes.mjs > notes.md
|
|
# SVG, PNG, PDF, EPS and webfont files built for the published packages
|
|
pnpm run zip
|
|
gh release create "v${VERSION}" "packages-zip/tabler-icons-${VERSION}.zip" --target "$GITHUB_SHA" --title "Release ${VERSION}" --notes-file notes.md
|
|
|