-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (69 loc) · 2.01 KB
/
release.yml
File metadata and controls
79 lines (69 loc) · 2.01 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
name: release
on:
push:
branches: [main]
tags: ["v*"]
jobs:
build:
name: build ${{ matrix.os }}/${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: linux
arch: amd64
- os: linux
arch: arm64
- os: darwin
arch: amd64
- os: darwin
arch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: build
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 0
run: |
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(git rev-parse --short HEAD)
BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
BINARY="queryit_${{ matrix.os }}_${{ matrix.arch }}"
go build \
-ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.buildDate=${BUILD_DATE}" \
-o "${BINARY}" .
tar czf "${BINARY}.tar.gz" "${BINARY}"
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: queryit_${{ matrix.os }}_${{ matrix.arch }}
path: queryit_${{ matrix.os }}_${{ matrix.arch }}.tar.gz
retention-days: 30
release:
name: github release
needs: build
runs-on: ubuntu-latest
# only publish a release when a tag is pushed
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--generate-notes \
dist/*.tar.gz