-
Notifications
You must be signed in to change notification settings - Fork 249
149 lines (133 loc) · 4.45 KB
/
goreleaser.yaml
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
143
144
145
146
147
148
149
name: goreleaser
on:
push:
branches:
- 'master'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request: {}
merge_group:
defaults:
run:
shell: bash
jobs:
release:
needs:
- build-windows
- build-darwin
- build-linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- run: |
for dist in dist-*; do
tar -C "${dist}" -xf "${dist}/${dist}.tar"
done
- name: Create assets
run: |
set -xe
mkdir -p assets
cat dist-*/dist/checksums.txt > assets/checksums.txt
for asset in dist-*/dist/*_*/*; do
base=$(basename "${asset}")
variant=$(basename $(dirname "${asset}") | cut -d_ -f1)
cp "${asset}" "assets/${variant}-${base}"
done
find assets -ls
cat assets/checksums.txt
- name: Upload Release Assets
if: github.ref_type == 'tag'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "${{ github.ref_name }}" --generate-notes ./assets/*
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
# GoReleaser requires fetch-depth: 0 to correctly
# run git describe
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: "Run GoReleaser"
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ARGS: release --skip=validate --clean -f release/goreleaser.windows.yaml ${{ github.event_name == 'pull_request' && '--snapshot' || '' }}
- run: tar -cvf dist-windows.tar dist
- uses: actions/upload-artifact@v4
with:
name: dist-windows
path: dist-windows.tar
build-darwin:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
# GoReleaser requires fetch-depth: 0 to correctly
# run git describe
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: "Run GoReleaser"
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ARGS: release --rm-dist -f release/goreleaser.darwin.yaml --skip=validate ${{ github.event_name == 'pull_request' && '--snapshot' || '' }}
- run: gtar -cvf dist-darwin.tar dist
- uses: actions/upload-artifact@v4
with:
name: dist-darwin
path: dist-darwin.tar
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# GoReleaser requires fetch-depth: 0 to correctly
# run git describe
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: "Install linux cross-compilers"
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-s390x-linux-gnu gcc-powerpc64le-linux-gnu
- name: "Set the image tag"
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
# Release tags.
echo IMAGE_TAG="${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
elif [[ $GITHUB_REF == refs/heads/* ]]; then
# Branch build.
echo IMAGE_TAG="$(echo "${GITHUB_REF#refs/heads/}" | sed -r 's|/+|-|g')" >> $GITHUB_ENV
elif [[ $GITHUB_REF == refs/pull/* ]]; then
# PR build.
echo IMAGE_TAG="pr-$(echo "${GITHUB_REF}" | sed -E 's|refs/pull/([^/]+)/?.*|\1|')" >> $GITHUB_ENV
else
echo IMAGE_TAG="$(git describe --tags --always)" >> $GITHUB_ENV
fi
- name: "Login to Quay"
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: "Run GoReleaser"
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ARGS: release --rm-dist -f release/goreleaser.linux.yaml --skip=validate ${{ github.event_name == 'pull_request' && '--snapshot' || '' }}
- run: tar -cvf dist-linux.tar dist
- uses: actions/upload-artifact@v4
with:
name: dist-linux
path: dist-linux.tar