Repository navigation
99 lines (83 loc) · 2.64 KB
/
Copy pathrelease.yml
File metadata and controls
99 lines (83 loc) · 2.64 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
name: release
on:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: write
jobs:
verify:
name: verify
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/[email protected]
- name: Install Go
uses: actions/[email protected]
with:
go-version-file: go.mod
check-latest: true
cache: true
cache-dependency-path: go.sum
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v2.12.2
args: --config=.golangci.yml ./...
- name: Test
shell: bash
run: make test
- name: Build
shell: bash
run: make build
release:
name: release
if: github.ref == 'refs/heads/master'
needs: verify
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- name: Install Go
uses: actions/[email protected]
with:
go-version-file: go.mod
check-latest: true
cache: true
cache-dependency-path: go.sum
- name: Prepare release version
id: version
shell: bash
run: |
tag="v0.1.${GITHUB_RUN_NUMBER}"
echo "tag=${tag}" >> "${GITHUB_OUTPUT}"
- name: Build release assets
shell: bash
run: |
mkdir -p dist
build_time="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
commit_hash="${GITHUB_SHA::7}"
version="${{ steps.version.outputs.tag }}"
ldflags="-X 'github.com/Format-C-eft/git-update/internal/config.version=${version}' -X 'github.com/Format-C-eft/git-update/internal/config.branch=${GITHUB_REF_NAME}' -X 'github.com/Format-C-eft/git-update/internal/config.commitHash=${commit_hash}' -X 'github.com/Format-C-eft/git-update/internal/config.timeBuild=${build_time}'"
for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do
goos="${target%/*}"
goarch="${target#*/}"
output="dist/git-update-${goos}-${goarch}"
CGO_ENABLED=0 GOOS="${goos}" GOARCH="${goarch}" \
go build -ldflags "${ldflags}" -o "${output}" ./cmd/git-update
done
sha256sum dist/* > dist/checksums.txt
- name: Create GitHub Release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.version.outputs.tag }}" \
dist/* \
--target "${GITHUB_SHA}" \
--generate-notes \
--fail-on-no-commits