This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (86 loc) · 2.61 KB
/
ci.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
name: ci
on:
push:
branches: [main]
paths-ignore: ['**.md', '.vscode/**', 'site/**']
pull_request:
branches: [main]
paths-ignore: ['**.md', '.vscode/**', 'site/**']
release:
types: [published]
workflow_dispatch:
permissions:
contents: write
jobs:
ci:
name: CI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go v1.21.4
uses: actions/setup-go@v5
with:
go-version: '1.21.4'
- name: Get tag and set version on release
if: startsWith(github.ref, 'refs/tags/v')
run: |
sed "s|version = \"v.*\"|version = \"$GITHUB_REF_NAME\"|" -i version.go
cat -n version.go
- name: Set VERSION, EXE, and ZIP env vars
run: |
VERSION="$GITHUB_REF_NAME"
if [[ $GITHUB_REF != "refs/tags/v"* ]]; then
VERSION="${GITHUB_SHA::7}"
fi
echo "VERSION=$VERSION" | tee -a "$GITHUB_ENV"
- name: Build
run: |
for OS in linux darwin freebsd; do
EXE="zsv-playground-$VERSION-amd64-$OS"
GOOS="$OS" GOARCH=amd64 go build -ldflags '-w -s' -o "$EXE"
ZIP="$EXE.zip"
zip "$ZIP" "$EXE"
echo "$(echo $OS | tr [:lower:] [:upper:])_ZIP=$ZIP" | tee -a "$GITHUB_ENV"
done
file zsv-playground*
ls -hl *.zip
- name: Upload [${{ env.LINUX_ZIP }}]
uses: actions/upload-artifact@v4
with:
name: ${{ env.LINUX_ZIP }}
path: ${{ env.LINUX_ZIP }}
if-no-files-found: error
- name: Upload ${{ env.DARWIN_ZIP }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.DARWIN_ZIP }}
path: ${{ env.DARWIN_ZIP }}
if-no-files-found: error
- name: Upload ${{ env.FREEBSD_ZIP }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.FREEBSD_ZIP }}
path: ${{ env.FREEBSD_ZIP }}
if-no-files-found: error
- name: Upload with release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
${{ env.LINUX_ZIP }}
${{ env.DARWIN_ZIP }}
${{ env.FREEBSD_ZIP }}
- name: Bump version on release [${{ env.VERSION }}]
if: startsWith(github.ref, 'refs/tags/v')
run: |
git config user.name 'github-actions[bot]'
git config user.email '[email protected]'
git checkout main
if [[ $(git diff version.go) != "" ]]; then
git add version.go
git commit -m "[CI] Bump version to $VERSION"
git push -u origin main
fi