-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (148 loc) · 5.17 KB
/
Copy pathrelease.yml
File metadata and controls
177 lines (148 loc) · 5.17 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
- name: Calculate version
id: bump
run: |
VERSION=$(npx --yes @circlesac/oneup version --target package.json | tail -1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
with:
name: versioned-files
path: package.json
build:
needs: version
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
target: bun-darwin-x64
name: tsk-darwin-x64
- os: macos-latest
target: bun-darwin-arm64
name: tsk-darwin-arm64
- os: ubuntu-latest
target: bun-linux-x64
name: tsk-linux-x64
- os: ubuntu-latest
target: bun-linux-arm64
name: tsk-linux-arm64
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
- uses: actions/download-artifact@v4
with:
name: versioned-files
- name: Build binary
run: |
bun build --compile --target=${{ matrix.target }} --outfile=tsk src/index.ts
if [[ "${{ matrix.target }}" == bun-darwin-* ]]; then
codesign --remove-signature tsk
codesign --force --deep -s - tsk
fi
tar czf ${{ matrix.name }}.tar.gz tsk
- name: Package Debian artifact
if: startsWith(matrix.target, 'bun-linux')
run: |
case "${{ matrix.target }}" in
bun-linux-x64) arch=amd64 ;;
bun-linux-arm64) arch=arm64 ;;
*) exit 1 ;;
esac
./packaging/build-deb.sh "tsk" "${{ needs.version.outputs.version }}" "$arch" .
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: |
${{ matrix.name }}.*
tsk_*.deb
release:
needs: [version, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.version.outputs.version }}
generate_release_notes: true
files: |
artifacts/**/*.tar.gz
artifacts/**/*.deb
bin/install.sh
publish-npm:
needs: [version, release]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- uses: actions/download-artifact@v4
with:
name: versioned-files
- name: Publish to npm
run: npm publish --access public
publish-package-indexes:
needs: [version, release, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Update Homebrew and APT indexes
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
VERSION=${{ needs.version.outputs.version }}
SHA_DARWIN_ARM64=$(shasum -a 256 artifacts/tsk-darwin-arm64/*.tar.gz | cut -d' ' -f1)
SHA_DARWIN_X64=$(shasum -a 256 artifacts/tsk-darwin-x64/*.tar.gz | cut -d' ' -f1)
SHA_LINUX_ARM64=$(shasum -a 256 artifacts/tsk-linux-arm64/*.tar.gz | cut -d' ' -f1)
SHA_LINUX_X64=$(shasum -a 256 artifacts/tsk-linux-x64/*.tar.gz | cut -d' ' -f1)
git clone https://x-access-token:${GH_TOKEN}@github.com/circlesac/homebrew-tap.git
cd homebrew-tap
cp ../homebrew/tsk.rb.template Formula/tsk.rb
sed -i "s/VERSION_PLACEHOLDER/${VERSION}/g" Formula/tsk.rb
sed -i "s/SHA_DARWIN_ARM64/${SHA_DARWIN_ARM64}/g" Formula/tsk.rb
sed -i "s/SHA_DARWIN_X64/${SHA_DARWIN_X64}/g" Formula/tsk.rb
sed -i "s/SHA_LINUX_ARM64/${SHA_LINUX_ARM64}/g" Formula/tsk.rb
sed -i "s/SHA_LINUX_X64/${SHA_LINUX_X64}/g" Formula/tsk.rb
mapfile -t packages < <(find ../artifacts -type f -name 'tsk_*.deb' | sort)
test "${#packages[@]}" -eq 2
for package in "${packages[@]}"; do
./apt/scripts/add-package.sh "$package" circlesac/tsk-cli "v${VERSION}"
done
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/tsk.rb "apt/manifests/tsk/${VERSION}"
git diff --cached --quiet && exit 0
git commit -m "Update tsk to ${VERSION}"
for attempt in 1 2 3; do
git pull --rebase origin main
if git push origin main; then
exit 0
fi
printf 'push attempt %s failed\n' "$attempt" >&2
done
exit 1