-
Notifications
You must be signed in to change notification settings - Fork 2
147 lines (141 loc) · 4.59 KB
/
release.yml
File metadata and controls
147 lines (141 loc) · 4.59 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Release
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write
issues: write
pull-requests: write
packages: write
id-token: write
jobs:
next-version:
name: Resolve next version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.resolve.outputs.version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- run: npm install -g npm@^11.5.1
- run: npm ci
- id: resolve
run: |
OUTPUT="$(npx semantic-release --dry-run --no-ci --plugins @semantic-release/commit-analyzer @semantic-release/release-notes-generator 2>&1 | tee /dev/stderr)"
VERSION="$(printf '%s\n' "$OUTPUT" | sed -nE 's/.*The next release version is ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' | tail -n 1)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PACKAGES_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-binaries:
name: Build ${{ matrix.asset_name }}
runs-on: ${{ matrix.os }}
needs: next-version
if: needs.next-version.outputs.version != ''
strategy:
matrix:
include:
- os: ubuntu-latest
asset_name: gh-attach-linux-amd64
pkg_target: node18-linux-x64
- os: macos-14
asset_name: gh-attach-darwin-amd64
pkg_target: node18-macos-x64
- os: macos-14
asset_name: gh-attach-darwin-arm64
pkg_target: node18-macos-arm64
- os: windows-latest
asset_name: gh-attach-windows-amd64.exe
pkg_target: node18-win-x64
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- run: npm install -g npm@^11.5.1
- run: npm ci
- run: npm run build
env:
GH_ATTACH_BUILD_VERSION: ${{ needs.next-version.outputs.version }}
- run: npm run package
env:
GH_ATTACH_BUILD_VERSION: ${{ needs.next-version.outputs.version }}
GH_ATTACH_PKG_TARGETS: ${{ matrix.pkg_target }}
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.asset_name }}
path: bin/${{ matrix.asset_name }}
validate-release-candidate:
name: Validate release candidate
runs-on: ubuntu-latest
needs: [next-version, build-binaries]
if: needs.next-version.outputs.version != ''
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- run: npm install -g npm@^11.5.1
- run: npm ci
- uses: actions/download-artifact@v8
with:
path: bin
pattern: gh-attach-*
merge-multiple: true
- name: Restore binary permissions
run: chmod +x bin/gh-attach-linux-amd64 bin/gh-attach-darwin-amd64 bin/gh-attach-darwin-arm64
- name: Verify packaged binaries
run: |
test -f bin/gh-attach-linux-amd64
test -f bin/gh-attach-darwin-amd64
test -f bin/gh-attach-darwin-arm64
test -f bin/gh-attach-windows-amd64.exe
- run: npm run build
env:
GH_ATTACH_BUILD_VERSION: ${{ needs.next-version.outputs.version }}
- run: npm test
env:
GH_ATTACH_BUILD_VERSION: ${{ needs.next-version.outputs.version }}
release:
name: Semantic Release
runs-on: ubuntu-latest
needs: [next-version, build-binaries, validate-release-candidate]
if: needs.next-version.outputs.version != ''
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- run: npm install -g npm@^11.5.1
- run: npm ci
- uses: actions/download-artifact@v8
with:
path: bin
pattern: gh-attach-*
merge-multiple: true
- name: Restore binary permissions
run: chmod +x bin/gh-attach-linux-amd64 bin/gh-attach-darwin-amd64 bin/gh-attach-darwin-arm64
- name: Verify packaged binaries
run: |
test -f bin/gh-attach-linux-amd64
test -f bin/gh-attach-darwin-amd64
test -f bin/gh-attach-darwin-arm64
test -f bin/gh-attach-windows-amd64.exe
- name: Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PACKAGES_TOKEN: ${{ secrets.GITHUB_TOKEN }}