-
-
Notifications
You must be signed in to change notification settings - Fork 2
128 lines (124 loc) · 3.97 KB
/
release.yml
File metadata and controls
128 lines (124 loc) · 3.97 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
name: Release
on:
push:
tags:
- 'v[0-9]*.[0-9]*.[0-9]*'
jobs:
build:
strategy:
matrix:
include:
- runner: macos-latest
target: aarch64-apple-darwin
node_target: darwin-arm64
- runner: macos-15-intel
target: x86_64-apple-darwin
node_target: darwin-x64
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
node_target: linux-x64
- runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
node_target: linux-arm64
- runner: windows-2022
target: x86_64-pc-windows-gnu
node_target: win32-x64
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
# Windows cgo build needs a GCC toolchain (pg_query_go uses -std=gnu99)
- name: Set up MinGW (Windows)
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
install: mingw-w64-x86_64-gcc
path-type: inherit
- name: Build
run: |
ext=""
[ "${{ runner.os }}" = "Windows" ] && ext=".exe"
CGO_ENABLED=1 go build \
-ldflags "-X main.version=${GITHUB_REF_NAME}" \
-o "dryrun${ext}" \
./cmd/dryrun
- name: Archive (tar.xz)
if: runner.os != 'Windows'
run: tar -cJf dry_run_cli-${{ matrix.target }}.tar.xz dryrun
- name: Archive (zip)
if: runner.os == 'Windows'
run: 7z a dry_run_cli-${{ matrix.target }}.zip dryrun.exe
- uses: actions/upload-artifact@v4
with:
name: tar-${{ matrix.target }}
path: dry_run_cli-${{ matrix.target }}.*
retention-days: 1
# raw binary for the npm platform packages
- uses: actions/upload-artifact@v4
with:
name: bin-${{ matrix.node_target }}
path: dryrun${{ runner.os == 'Windows' && '.exe' || '' }}
retention-days: 1
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: tar-*
merge-multiple: true
path: dist/
- name: Checksums
run: cd dist && shasum -a 256 *.tar.xz *.zip > checksums.txt
- name: Publish release
run: |
gh release create "$GITHUB_REF_NAME" \
--title "$GITHUB_REF_NAME" \
--generate-notes \
dist/*.tar.xz dist/*.zip dist/checksums.txt
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm-publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- uses: actions/download-artifact@v4
with:
pattern: bin-*
path: bins/
- name: Stage binaries
run: |
for t in darwin-arm64 darwin-x64 linux-x64 linux-arm64; do
mkdir -p npm/packages/$t/bin
cp bins/bin-$t/dryrun npm/packages/$t/bin/dryrun
chmod +x npm/packages/$t/bin/dryrun
done
mkdir -p npm/packages/win32-x64/bin
cp bins/bin-win32-x64/dryrun.exe npm/packages/win32-x64/bin/dryrun.exe
- name: Set versions
run: node npm/scripts/set-version.mjs "${GITHUB_REF_NAME#v}"
- name: Publish platform packages
run: |
for t in darwin-arm64 darwin-x64 linux-x64 linux-arm64 win32-x64; do
npm publish --access public ./npm/packages/$t
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish launcher package
run: npm publish --access public ./npm/dryrun
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}