-
Notifications
You must be signed in to change notification settings - Fork 2
103 lines (90 loc) · 3.57 KB
/
Copy pathrelease.yml
File metadata and controls
103 lines (90 loc) · 3.57 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
name: Release
on:
workflow_dispatch:
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
github_release:
name: GitHub Release
runs-on: ubuntu-24.04
steps:
- uses: actions/create-github-app-token@v3.2.0
id: app-token
with:
client-id: ${{ secrets.BOT_GH_APP_ID }}
private-key: ${{ secrets.BOT_GH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: |
${{ github.event.repository.name }}
- uses: actions/checkout@v7.0.0
with:
ref: ${{ github.ref }}
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Set up Git
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
git config --global commit.gpgsign false
git config --global commit.signoff true
- name: Setup Node.js
uses: actions/setup-node@v6.4.0
with:
node-version: '24'
- name: Install semantic release and plugins
run: |
mkdir -p "$RUNNER_TEMP/semantic-release"
cat > "$RUNNER_TEMP/semantic-release/package.json" <<'EOF'
{
"private": true,
"devDependencies": {
"semantic-release": "25.0.5",
"@semantic-release/commit-analyzer": "13.0.1",
"@semantic-release/release-notes-generator": "14.1.1",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/exec": "7.1.0",
"@semantic-release/git": "10.0.1",
"@semantic-release/github": "12.0.9",
"conventional-changelog-conventionalcommits": "10.2.0"
},
"overrides": {
"conventional-changelog-writer": "^9.1.0"
}
}
EOF
npm install --prefix "$RUNNER_TEMP/semantic-release"
echo "$RUNNER_TEMP/semantic-release/node_modules/.bin" >> "$GITHUB_PATH"
- name: Create a release if needed
id: semantic
env:
CI: true
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
GIT_AUTHOR_NAME: ${{ steps.app-token.outputs.app-slug }}[bot]
GIT_AUTHOR_EMAIL: ${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ steps.app-token.outputs.app-slug }}[bot]
GIT_COMMITTER_EMAIL: ${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com
run: |
if ! gh release view 0.1.0 >/dev/null 2>&1; then
gh release create 0.1.0 --title "Initial Release" --notes "Initial Release" --target main
fi
DRY_OUTPUT=$(semantic-release --dry-run 2>&1 || true)
if $(echo "$DRY_OUTPUT" | grep -q "no new version is released"); then
echo "No new release needed"
exit 0
fi
if semantic-release; then
echo "Released successfully"
else
echo "Release failed"
exit 1
fi