This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
117 lines (112 loc) · 3.29 KB
/
main.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
name: Release
on:
workflow_dispatch:
push:
tags:
- "v*"
env:
GO_VERSION: "1.22.x"
jobs:
build:
name: Build Binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-22.04, macos-latest ]
steps:
- uses: actions/checkout@v4
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
- name: Setup CI Tools
run: make ci-setup
- name: Run Go Tests
run: make test
- name: Install Homebrew on macOS
if: runner.os == 'macOS'
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
brew install mingw-w64
- name: Build Binary
run: make build-cross
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-artifacts
path: dist/*
retention-days: 1
if-no-files-found: error
collect-artifacts:
name: Collect Artifacts and Generate Checksums
runs-on: ubuntu-22.04
needs: build
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: ubuntu-22.04-artifacts
path: dist
merge-multiple: true
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: macos-latest-artifacts
path: dist
merge-multiple: true
- name: Calculate Checksums
run: |
cd dist
sha256sum knowledge-* > checksums.txt
- name: Upload Checksums
uses: actions/upload-artifact@v4
with:
name: checksums
path: dist/checksums.txt
release:
name: Create Release
runs-on: ubuntu-22.04
needs: collect-artifacts
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: ubuntu-22.04-artifacts
path: dist
merge-multiple: true
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: macos-latest-artifacts
path: dist
- name: Download Checksums
uses: actions/download-artifact@v4
with:
name: checksums
path: dist
merge-multiple: true
- name: Extract Tag from Ref
if: startsWith(github.ref, 'refs/tags/')
id: tag
run: echo VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT
shell: bash
- uses: apexskier/github-semver-parse@v1
if: startsWith(github.ref, 'refs/tags/')
id: semver
with:
version: ${{ steps.tag.outputs.VERSION }}
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: |
dist/*
makeLatest: ${{ steps.semver.outputs.prerelease == '' }}
generateReleaseNotes: true
prerelease: ${{ steps.semver.outputs.prerelease != '' }}
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}