-
Notifications
You must be signed in to change notification settings - Fork 16
142 lines (122 loc) · 4.67 KB
/
release.yml
File metadata and controls
142 lines (122 loc) · 4.67 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
name: Release Build
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
- os: ubuntu-24.04-arm
goos: linux
goarch: arm64
- os: macos-latest
goos: darwin
goarch: arm64
- os: macos-15
goos: darwin
goarch: amd64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: go.mod
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "1"
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
go build -ldflags "-X main.version=build-${SHORT_SHA} -X main.commit=${{ github.sha }} -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o duckgres-${{ matrix.goos }}-${{ matrix.goarch }} .
- name: Upload artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: duckgres-${{ matrix.goos }}-${{ matrix.goarch }}
path: duckgres-${{ matrix.goos }}-${{ matrix.goarch }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Download all artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: artifacts
- name: Get short SHA
id: sha
run: echo "short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Generate checksums
run: |
cd artifacts
sha256sum \
duckgres-linux-amd64/duckgres-linux-amd64 \
duckgres-linux-arm64/duckgres-linux-arm64 \
duckgres-darwin-arm64/duckgres-darwin-arm64 \
duckgres-darwin-amd64/duckgres-darwin-amd64 | \
sed 's|duckgres-[^/]*/||g' > checksums.txt
cat checksums.txt
- name: Check if build release already exists
id: check-existing
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: "build-${{ steps.sha.outputs.short }}"
run: |
if gh release view "$TAG" &>/dev/null; then
echo "Release $TAG already exists — skipping to avoid overwriting a promoted release"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Create Release
if: steps.check-existing.outputs.exists == 'false'
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
tag_name: build-${{ steps.sha.outputs.short }}
name: Build ${{ steps.sha.outputs.short }}
prerelease: true
make_latest: false
body: |
Automated build from commit ${{ github.sha }}
To promote this build to customer ducklings: edit this release and uncheck "pre-release".
files: |
artifacts/duckgres-linux-amd64/duckgres-linux-amd64
artifacts/duckgres-linux-arm64/duckgres-linux-arm64
artifacts/duckgres-darwin-arm64/duckgres-darwin-arm64
artifacts/duckgres-darwin-amd64/duckgres-darwin-amd64
artifacts/checksums.txt
- name: Delete existing latest release
run: gh release delete latest --yes || true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update latest tag
run: |
git tag -f latest
git push -f origin latest
- name: Create latest release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
tag_name: latest
name: Latest Build
prerelease: true
make_latest: false
body: |
Latest build from commit ${{ github.sha }}
This is a **pre-release** (canary). It auto-deploys to dev and canary ducklings.
To promote a build to customer ducklings: find the specific `build-*` release and uncheck "pre-release".
files: |
artifacts/duckgres-linux-amd64/duckgres-linux-amd64
artifacts/duckgres-linux-arm64/duckgres-linux-arm64
artifacts/duckgres-darwin-arm64/duckgres-darwin-arm64
artifacts/duckgres-darwin-amd64/duckgres-darwin-amd64
artifacts/checksums.txt