-
Notifications
You must be signed in to change notification settings - Fork 0
202 lines (177 loc) · 6.72 KB
/
Copy pathbackfill-release-assets.yml
File metadata and controls
202 lines (177 loc) · 6.72 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Backfill Release Assets
on:
workflow_dispatch:
inputs:
tag_name:
description: Release tag whose binary assets should be rebuilt, for example v1.0.1
required: true
type: string
permissions: {}
jobs:
validate-release-tag:
name: Validate release tag
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
outputs:
tag_name: ${{ steps.validate.outputs.tag_name }}
steps:
- name: Validate tag name
id: validate
env:
TAG_NAME: ${{ inputs.tag_name }}
run: |
if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid release tag." >&2
exit 1
fi
printf 'tag_name=%s\n' "$TAG_NAME" >> "$GITHUB_OUTPUT"
build-unix-binaries:
name: Build ${{ matrix.os }} release assets
needs:
- validate-release-tag
runs-on: ${{ matrix.os }}
timeout-minutes: 30
environment:
name: release
deployment: false
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
asset_os: linux
asset_arch: amd64
- os: macos-latest
asset_os: darwin
asset_arch: arm64
steps:
- name: Create release bot token
id: release-bot
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.PUTIO_RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.PUTIO_RELEASE_BOT_PRIVATE_KEY }}
permission-contents: write
- name: Check out repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
ref: ${{ needs.validate-release-tag.outputs.tag_name }}
persist-credentials: false
- name: Read Vite+ version
id: tool-versions
shell: bash
run: |
version=$(jq -er '.devDependencies["vite-plus"] | sub("^[~^]"; "")' package.json)
echo "vite-plus-version=${version}" >> "$GITHUB_OUTPUT"
- name: Set up Vite+
uses: voidzero-dev/setup-vp@2dec1e33f4ab2c6d5bce1b0c4607961bb1a3f7a1 # v1.12.0
with:
version: ${{ steps.tool-versions.outputs.vite-plus-version }}
node-version-file: ".node-version"
cache: false
- name: Install dependencies
run: vp install
- name: Build SEA binary
run: vp run build:sea
- name: Verify SEA binary
run: vp run verify:sea
- name: Package release assets
shell: pwsh
env:
TAG_NAME: ${{ needs.validate-release-tag.outputs.tag_name }}
run: |
$version = $env:TAG_NAME.TrimStart("v")
$assetBase = "putio-cli-$version-${{ matrix.asset_os }}-${{ matrix.asset_arch }}"
$releaseDir = ".artifacts/release"
New-Item -ItemType Directory -Force -Path $releaseDir | Out-Null
$binaryPath = ".artifacts/sea/putio"
$stageDir = "$releaseDir/stage"
New-Item -ItemType Directory -Force -Path $stageDir | Out-Null
Copy-Item $binaryPath "$stageDir/putio"
tar -czf "$releaseDir/$assetBase.tar.gz" -C $stageDir putio
Remove-Item -Recurse -Force $stageDir
$assetPath = "$releaseDir/$assetBase.tar.gz"
$hash = (Get-FileHash -Algorithm SHA256 $assetPath).Hash.ToLower()
"$hash $(Split-Path $assetPath -Leaf)" | Out-File "$assetPath.sha256" -Encoding ascii -NoNewline
- name: Generate SHA-256 checksums
shell: pwsh
run: Get-ChildItem .artifacts/release
- name: Upload binary assets to the GitHub release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3
with:
token: ${{ steps.release-bot.outputs.token }}
tag_name: ${{ needs.validate-release-tag.outputs.tag_name }}
files: |
.artifacts/release/*
build-windows-binary:
name: Build windows-latest release assets
needs:
- validate-release-tag
runs-on: windows-latest
timeout-minutes: 30
environment:
name: release
deployment: false
permissions:
contents: read
steps:
- name: Create release bot token
id: release-bot
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.PUTIO_RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.PUTIO_RELEASE_BOT_PRIVATE_KEY }}
permission-contents: write
- name: Check out repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
ref: ${{ needs.validate-release-tag.outputs.tag_name }}
persist-credentials: false
- name: Read Vite+ version
id: tool-versions
shell: bash
run: |
version=$(jq -er '.devDependencies["vite-plus"] | sub("^[~^]"; "")' package.json)
echo "vite-plus-version=${version}" >> "$GITHUB_OUTPUT"
- name: Set up Vite+
uses: voidzero-dev/setup-vp@2dec1e33f4ab2c6d5bce1b0c4607961bb1a3f7a1 # v1.12.0
with:
version: ${{ steps.tool-versions.outputs.vite-plus-version }}
node-version-file: ".node-version"
cache: false
- name: Install dependencies
run: vp install
- name: Build SEA binary
run: vp run build:sea
- name: Verify SEA binary
run: vp run verify:sea
- name: Package release assets
shell: pwsh
env:
TAG_NAME: ${{ needs.validate-release-tag.outputs.tag_name }}
run: |
$version = $env:TAG_NAME.TrimStart("v")
$assetBase = "putio-cli-$version-windows-amd64"
$releaseDir = ".artifacts/release"
New-Item -ItemType Directory -Force -Path $releaseDir | Out-Null
$binaryPath = ".artifacts/sea/putio.exe"
Compress-Archive -Path $binaryPath -DestinationPath "$releaseDir/$assetBase.zip" -Force
$assetPath = "$releaseDir/$assetBase.zip"
$hash = (Get-FileHash -Algorithm SHA256 $assetPath).Hash.ToLower()
"$hash $(Split-Path $assetPath -Leaf)" | Out-File "$assetPath.sha256" -Encoding ascii -NoNewline
- name: Generate SHA-256 checksums
shell: pwsh
run: Get-ChildItem .artifacts/release
- name: Upload binary assets to the GitHub release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3
with:
token: ${{ steps.release-bot.outputs.token }}
tag_name: ${{ needs.validate-release-tag.outputs.tag_name }}
files: |
.artifacts/release/*