-
Notifications
You must be signed in to change notification settings - Fork 11
80 lines (71 loc) · 2.42 KB
/
prepare-release.yml
File metadata and controls
80 lines (71 loc) · 2.42 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: 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