-
-
Notifications
You must be signed in to change notification settings - Fork 15
252 lines (221 loc) · 6.62 KB
/
Copy pathrelease.yml
File metadata and controls
252 lines (221 loc) · 6.62 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag_name:
required: true
type: string
platforms:
default: "linux,macos,windows"
type: string
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: false
jobs:
validate-tag-name:
runs-on: ubuntu-latest
steps:
- name: Validate tag name format
env:
TAG_NAME: ${{ inputs.tag_name || github.ref_name }}
run: |
if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Invalid tag name format: $TAG_NAME (expected vX.Y.Z)"
exit 1
fi
linux:
needs: validate-tag-name
runs-on: ubuntu-latest
if: ${{ !inputs.platforms || contains(inputs.platforms, 'linux') }}
env:
TAG_NAME: ${{ inputs.tag_name || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: "~> v2"
install-only: true
- name: Create temporary tag
if: github.event_name == 'workflow_dispatch'
run: git tag "$TAG_NAME"
- name: Install cross-compilers
run: |
sudo apt-get install -y \
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
gcc-i686-linux-gnu g++-i686-linux-gnu \
gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
- name: Build release binaries
run: bash script/release --local "$TAG_NAME" --platform linux
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
with:
name: dist-linux
if-no-files-found: error
retention-days: 7
path: |
dist/*.tar.gz
dist/*.rpm
dist/*.deb
dist/*.apk
dist/*.zst
macos:
needs: validate-tag-name
runs-on: macos-latest
if: ${{ !inputs.platforms || contains(inputs.platforms, 'macos') }}
env:
TAG_NAME: ${{ inputs.tag_name || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: "~> v2"
install-only: true
- name: Create temporary tag
if: github.event_name == 'workflow_dispatch'
run: git tag "$TAG_NAME"
- name: Build release binaries
run: bash script/release --local "$TAG_NAME" --platform macos
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
with:
name: dist-darwin
if-no-files-found: error
retention-days: 7
path: |
dist/*.tar.gz
dist/*.zip
windows:
needs: validate-tag-name
runs-on: windows-2022
if: ${{ !inputs.platforms || contains(inputs.platforms, 'windows') }}
env:
TAG_NAME: ${{ inputs.tag_name || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
install: mingw-w64-x86_64-gcc
update: true
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: "~> v2"
install-only: true
- name: Create temporary tag
shell: bash
run: git tag "$TAG_NAME"
if: github.event_name == 'workflow_dispatch'
- name: Build release binaries
shell: bash
run: bash script/release --local "$TAG_NAME" --platform windows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up MSBuild
id: setupmsbuild
uses: microsoft/setup-msbuild@v2
- name: Install WiX Toolset
run: choco install wixtoolset -y --no-progress
shell: pwsh
- name: Build MSI
shell: bash
env:
MSBUILD_PATH: ${{ steps.setupmsbuild.outputs.msbuildPath }}
VERSION: ${{ env.TAG_NAME }}
run: |
version="${VERSION#v}"
for ZIP_FILE in dist/pgxcli_*_windows_*.zip; do
MSI_NAME="$(basename "$ZIP_FILE" ".zip")"
case "$MSI_NAME" in
*_amd64 )
source_dir="$PWD/dist/pgxcli-windows_windows_amd64_v1/"
platform="x64"
;;
* )
printf "unsupported architecture: %s\n" "$MSI_NAME" >&2
exit 1
;;
esac
"${MSBUILD_PATH}\\MSBuild.exe" build/windows/pgxcli.wixproj \
-p:SourceDir="$source_dir" \
-p:OutputPath="$PWD/dist" \
-p:OutputName="pgxcli_${version}_windows_amd64" \
-p:ProductVersion="$version" \
-p:Platform="$platform" \
-p:Configuration=Release
done
- uses: actions/upload-artifact@v4
with:
name: dist-windows
if-no-files-found: error
retention-days: 7
path: |
dist/*.zip
dist/*.msi
release:
runs-on: ubuntu-latest
needs: [linux, macos, windows]
if: always() && !contains(needs.*.result, 'failure')
env:
TAG_NAME: ${{ inputs.tag_name || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: dist-*
path: dist/
merge-multiple: true
- name: Generate checksums
run: |
cd dist
VERSION="${TAG_NAME#v}"
shasum -a 256 pgxcli_* > "pgxcli_${VERSION}_checksums.txt"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG_NAME }}
draft: true
prerelease: ${{ contains(env.TAG_NAME, '-') }}
generate_release_notes: true
files: |
dist/*.tar.gz
dist/*.zip
dist/*.msi
dist/*.deb
dist/*.rpm
dist/*.apk
dist/*.zst
dist/*checksums*.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}