-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (81 loc) · 2.54 KB
/
Copy pathrelease.yaml
File metadata and controls
86 lines (81 loc) · 2.54 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
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
packages: write
env:
MAIN_PACKAGE: "./cmd/gqlgate"
jobs:
binaries:
name: Build and publish the binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Test
run: go test -race ./...
- name: Cross-compile
env:
VERSION: ${{ github.ref_name }}
BIN: ${{ github.event.repository.name }}
run: |
mkdir -p dist
for platform in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64; do
os=${platform%/*} arch=${platform#*/}
bin=$BIN; [ "$os" = windows ] && bin=$BIN.exe
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath \
-ldflags="-s -w -X main.version=${VERSION}" \
-o "dist/$bin" "$MAIN_PACKAGE"
name="${BIN}_${VERSION#v}_${os}_${arch}"
if [ "$os" = windows ]; then
(cd dist && zip -q "$name.zip" "$bin")
else
tar -C dist -czf "dist/$name.tar.gz" "$bin"
fi
rm "dist/$bin"
done
- name: Checksums
run: cd dist && sha256sum -- * > checksums.txt
- name: Create GitHub release
# Skipped under act (local workflow testing); act sets ACT=true.
if: ${{ !env.ACT }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" \
--title "$GITHUB_REF_NAME" \
--generate-notes \
dist/*
docker:
name: Publish the image to GHCR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
if: ${{ !env.ACT }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ !env.ACT }}
build-args: VERSION=${{ github.ref_name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}