-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (77 loc) · 2.83 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
name: Build and Release fixctl
on:
push:
tags:
- "*.*.*"
branches:
- main
jobs:
build:
name: Build fixctl on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
go-version: [1.22]
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Check out code
uses: actions/checkout@v4
- name: Set up environment
shell: bash
run: |
OS_NAME=$(echo ${{ matrix.os }} | sed 's/-latest//')
SUFFIX=""
if [ $OS_NAME = "windows" ]; then
SUFFIX=".exe"
fi
if [ $OS_NAME = "ubuntu" ]; then
OS_NAME="linux"
fi
echo "SUFFIX=$SUFFIX" >> $GITHUB_ENV
echo "OS_NAME=$OS_NAME" >> $GITHUB_ENV
- name: Build Binary (amd64)
run: |
GOARCH=amd64 go build -ldflags "-s -w" -o "${{ github.workspace }}/release/fixctl-$OS_NAME-amd64-${{ github.ref_name }}$SUFFIX"
shell: bash
- name: Build Binary (arm64)
run: |
GOARCH=arm64 go build -ldflags "-s -w" -o "${{ github.workspace }}/release/fixctl-$OS_NAME-arm64-${{ github.ref_name }}$SUFFIX"
shell: bash
- name: Generate Universal Binary (macOS)
if: matrix.os == 'macos-latest'
run: |
lipo -create -output "${{ github.workspace }}/release/fixctl-$OS_NAME-universal-${{ github.ref_name }}$SUFFIX" "${{ github.workspace }}/release/fixctl-$OS_NAME-amd64-${{ github.ref_name }}$SUFFIX" "${{ github.workspace }}/release/fixctl-$OS_NAME-arm64-${{ github.ref_name }}$SUFFIX"
rm -f "${{ github.workspace }}/release/fixctl-$OS_NAME-amd64-${{ github.ref_name }}$SUFFIX" "${{ github.workspace }}/release/fixctl-$OS_NAME-arm64-${{ github.ref_name }}$SUFFIX"
strip "${{ github.workspace }}/release/fixctl-$OS_NAME-universal-${{ github.ref_name }}$SUFFIX"
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: fixctl-${{ matrix.os }}-${{ github.ref_name }}
path: ${{ github.workspace }}/release/
create_release:
name: Create Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/release
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: false
files: |
${{ github.workspace }}/release/*/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}