Prepare Release #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Prepare Release | |
| on: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: | |
| - completed | |
| jobs: | |
| version: | |
| if: > | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.head_branch == 'master' && | |
| !startsWith(github.event.workflow_run.head_commit.message, 'chore(release)') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.workflow_run.head_repository.full_name }} | |
| ref: ${{ github.event.workflow_run.head_commit.id }} | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: pnpm | |
| - name: Install dependencies | |
| env: | |
| LAME_SKIP_DOWNLOAD: "1" | |
| run: pnpm install --frozen-lockfile | |
| - name: Determine changelog mode | |
| id: changelog | |
| run: | | |
| git fetch --tags --force >/dev/null 2>&1 || true | |
| if git rev-parse "v2.0.0" >/dev/null 2>&1; then | |
| echo "skip=0" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "skip=1" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Bump version and changelog | |
| id: version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SKIP_CHANGELOG: ${{ steps.changelog.outputs.skip }} | |
| run: | | |
| set -eo pipefail | |
| git checkout -B master ${{ github.event.workflow_run.head_commit.id }} | |
| pnpm run release:version > version.log 2>&1 || STATUS=$? | |
| cat version.log | |
| if [ -n "$STATUS" ]; then | |
| if grep -q "No changed packages" version.log; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| exit "$STATUS" | |
| fi | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Push release commit and tags | |
| if: steps.version.outputs.skip != 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: git push --set-upstream origin master --follow-tags |