-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (115 loc) · 3.34 KB
/
release.yml
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
name: Release
on: [push]
permissions:
contents: write
env:
GO_VERSION: '>=1.21.0'
NAME: 'inflater'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
arch: [ amd64, arm64 ]
exclude:
- os: windows-latest
arch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup env
id: setup
shell: bash
run: |
if [[ ${GITHUB_REF} =~ ^refs/tags/v[0-9]+\.[0-9]+ ]] ; then
export VERSION=${GITHUB_REF_NAME}
else
export VERSION=SNAPSHOT
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
case ${{ matrix.os }} in
ubuntu-*)
if [ "${{ matrix.arch }}" = "arm64" ] ; then
sudo apt-get update
sudo apt-get -y install gcc-12-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc-12" >> $GITHUB_ENV
fi
export GOOS=linux
export PKGEXT=.tar.gz
;;
macos-*)
export GOOS=darwin
export PKGEXT=.zip
;;
windows-*)
choco install zip
export GOOS=windows
export PKGEXT=.zip
;;
esac
export GOARCH=${{ matrix.arch }}
echo "GOOS=${GOOS}" >> $GITHUB_ENV
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV
echo "PKGNAME=${NAME}_${VERSION}_${GOOS}_${GOARCH}" >> $GITHUB_ENV
echo "PKGEXT=${PKGEXT}" >> $GITHUB_ENV
- name: Build
shell: bash
run: |
go build
- name: Archive
shell: bash
run: |
rm -rf _build/${PKGNAME}
mkdir -p _build/${PKGNAME}
cp -p ${NAME} _build/${PKGNAME}
cp -p LICENSE _build/${PKGNAME}
cp -p README.md _build/${PKGNAME}
case "${PKGEXT}" in
".tar.gz")
tar cf _build/${PKGNAME}${PKGEXT} -C _build ${PKGNAME}
;;
".zip")
(cd _build && zip -r9q ${PKGNAME}${PKGEXT} ${PKGNAME})
;;
esac
ls -laFR _build
- name: Artifact upload
uses: actions/upload-artifact@v4
with:
name: ${{ env.GOOS }}_${{ env.GOARCH }}
path: _build/${{ env.PKGNAME }}${{ env.PKGEXT }}
create-release:
name: Create release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
steps:
- uses: actions/download-artifact@v4
with: { name: darwin_amd64 }
- uses: actions/download-artifact@v4
with: { name: darwin_arm64 }
- uses: actions/download-artifact@v4
with: { name: linux_amd64 }
- uses: actions/download-artifact@v4
with: { name: linux_arm64 }
- uses: actions/download-artifact@v4
with: { name: windows_amd64 }
- run: ls -lafR
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: ${{ contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') }}
files: |
*.tar.gz
*.zip
fail_on_unmatched_files: true
generate_release_notes: true
append_body: true
# based on: github.com/koron-go/_skeleton/.github/workflows/release.yml