forked from kelseyhightower/confd
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (60 loc) · 1.88 KB
/
build-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
# .github/workflows/build-release.yml
name: Build Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.23.1]
os: [linux, windows, darwin]
arch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Set up variables
run: |
GITSHA=$(git rev-parse --short HEAD)
echo GITSHA=$GITSHA >>$GITHUB_ENV
echo VERSION=${GITHUB_REF#refs/tags/} >>$GITHUB_ENV
- name: Define the executable name for Linux and macOS
if: ${{ matrix.os != 'windows' }}
run: echo CONFD=confd-${{ matrix.os }}-${{ matrix.arch }} >>$GITHUB_ENV
- name: Define the executable name for Windows
if: ${{ matrix.os == 'windows' }}
run: echo CONFD=confd-${{ matrix.os }}-${{ matrix.arch }}.exe >>$GITHUB_ENV
- name: Build `confd`
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: go build -o bin/$CONFD -ldflags "-s -w -X main.Version=$VERSION -X main.GitSHA=$GITSHA"
- name: Compress `confd`
if: ${{ matrix.os != 'windows' }}
run: upx --brute bin/$CONFD
- name: Upload `confd`
uses: actions/upload-artifact@v4
with:
name: ${{ env.CONFD }}
path: bin/${{ env.CONFD }}
publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download `confd`
uses: actions/download-artifact@v4
with:
path: bin
- name: Create release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: bin/*
# vim:set sw=2 ts=2 et: