And also publish packages with unreleased changes tagged with `next` to NPM
72 lines
2 KiB
YAML
72 lines
2 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
jobs:
|
|
release:
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
pull-requests: write
|
|
actions: read
|
|
id-token: write
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.PAT_GITHUB_TOKEN }}
|
|
persist-credentials: false
|
|
fetch-depth: 0
|
|
|
|
- uses: pnpm/action-setup@v4.0.0
|
|
|
|
- name: Setup Node.js environment
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20.9.0
|
|
cache: 'pnpm'
|
|
|
|
- name: Install Dependencies
|
|
run: pnpm install
|
|
|
|
- name: Create Release Pull Request
|
|
id: changesets
|
|
uses: aboviq/changesets-action@main
|
|
with:
|
|
publish: pnpm run release
|
|
commit: 'chore(release): version packages'
|
|
title: 'chore(release): version packages'
|
|
createGithubReleases: aggregate
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB_TOKEN }}
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
- name: Release to @next tag on npm
|
|
if: github.ref_name == 'main' && steps.changesets.outputs.published != 'true'
|
|
run: |
|
|
git checkout main
|
|
|
|
CHANGESET_FILE=$(git diff-tree --no-commit-id --name-only HEAD -r ".changeset/*-*-*.md")
|
|
if [ -z "$CHANGESET_FILE" ]; then
|
|
echo "No changesets found, skipping release to @next tag"
|
|
exit 0
|
|
fi
|
|
|
|
AFFECTED_PACKAGES=$(sed -n '/---/,/---/p' "$CHANGESET_FILE" | sed '/---/d')
|
|
if [ -z "$AFFECTED_PACKAGES" ]; then
|
|
echo "No packages affected by changesets, skipping release to @next tag"
|
|
exit 0
|
|
fi
|
|
|
|
pnpm changeset version --snapshot next
|
|
pnpm changeset publish --tag next
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB_TOKEN }}
|