-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (97 loc) · 2.9 KB
/
go-build.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
name: Build
on:
push:
branches:
- master
tags:
- 'v*.*.*' # Match version tags, e.g., v1.0.0
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
include:
- goos: linux
goarch: amd64
dir: linux
extension: ""
- goos: linux
goarch: arm64
dir: linux
extension: ""
- goos: windows
goarch: amd64
dir: win
extension: ".exe"
- goos: windows
goarch: arm64
dir: win
extension: ".exe"
- goos: darwin
goarch: amd64
dir: macos
extension: ""
- goos: darwin
goarch: arm64
dir: macos
extension: ""
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '^1.22'
cache: false
- name: Install dependencies
run: go mod tidy
- name: Build
run: |
mkdir -p ${{ matrix.dir }}
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o ${{ matrix.dir }}/rune-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }} ./dist
- name: Archive Artifacts
run: |
tar -czvf ${{ matrix.dir }}/rune-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz -C ${{ matrix.dir }} rune-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: rune-${{ matrix.goos }}-${{ matrix.goarch }}
path: ${{ matrix.dir }}/rune-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Release notes for version ${{ github.ref }}.
draft: false
prerelease: false
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for file in ./artifacts/**/*.tar.gz; do
filename=$(basename "$file")
gh release upload ${{ github.ref }} "$file" --clobber --repo ${{ github.repository }}
done