Repository navigation
80 lines (70 loc) · 2.88 KB
/
Copy pathrelease.yml
File metadata and controls
80 lines (70 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Release
on:
workflow_dispatch:
permissions:
contents: write
issues: write
pull-requests: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
working-directory: packages
run: yarn install
- name: Test
working-directory: packages
run: yarn test
- name: Release
id: release
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
set -o pipefail
npx -p semantic-release -p @semantic-release/git -p @semantic-release/exec semantic-release 2>&1 | tee release-output.log
# semantic-release's git-notes push (refs/notes/semantic-release-*) is unconditional,
# core behavior with no config to disable it - see semantic-release/semantic-release#1762.
# It runs before the npm/GitHub publish steps, so when the remote rejects it, the real
# publish never happens even though the version bump, build, commit, and tag already
# landed. This repo only ever releases from one branch, so the notes (used for
# multi-channel tracking) aren't needed - finish the release manually in that one case.
- name: Detect known git-notes push failure
id: notes-failure
if: steps.release.outcome == 'failure'
run: |
if grep -q "refs/notes/semantic-release" release-output.log; then
echo "Release step failed on the known git-notes push issue - falling back to a manual publish."
echo "matched=true" >> "$GITHUB_OUTPUT"
else
echo "Release step failed for a different reason - not falling back."
exit 1
fi
- name: Fallback publish (after known git-notes push failure)
if: steps.notes-failure.outputs.matched == 'true'
working-directory: packages
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
# Scoped to this step only - setup-node's registry-url would otherwise
# export NPM_CONFIG_USERCONFIG for the whole job and break the normal
# Release step's own (unrelated) npm auth, which expects NPM_TOKEN directly.
npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}"
VERSION=$(node -p "require('./package.json').version")
TAG="v${VERSION}"
echo "Publishing ${TAG} to npm and creating the GitHub release..."
npm publish
gh release create "$TAG" --title "$TAG" --generate-notes