-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (130 loc) · 3.98 KB
/
Copy pathrelease.yml
File metadata and controls
135 lines (130 loc) · 3.98 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.25'
cache: true
- run: go vet ./...
- run: go test -race ./...
licenses:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.25'
cache: true
- name: Generate THIRD_PARTY_LICENSES
run: |
set -euo pipefail
go install github.com/google/go-licenses@v1.6.0
TMP="$(mktemp -d)"
"$(go env GOPATH)/bin/go-licenses" save ./cmd/mythy \
--save_path="$TMP/lic" \
--ignore github.com/gridsociety/mythy \
--force
{
echo "Third-party licenses bundled with mythy"
echo "========================================"
echo
find "$TMP/lic" -type f | sort | while read -r f; do
mod="$(dirname "${f#$TMP/lic/}")"
echo "## $mod"
echo "----------------------------------------"
echo
cat "$f"
echo
echo
done
} > THIRD_PARTY_LICENSES
- uses: actions/upload-artifact@v7
with:
name: third-party-licenses
path: THIRD_PARTY_LICENSES
if-no-files-found: error
retention-days: 1
build:
needs: [test, licenses]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { goos: linux, goarch: '386' }
- { goos: linux, goarch: amd64 }
- { goos: linux, goarch: arm, goarm: '7' }
- { goos: linux, goarch: arm64 }
- { goos: darwin, goarch: amd64 }
- { goos: darwin, goarch: arm64 }
- { goos: windows, goarch: '386' }
- { goos: windows, goarch: amd64 }
- { goos: windows, goarch: arm64 }
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.25'
cache: true
- uses: actions/download-artifact@v8
with:
name: third-party-licenses
path: .
- name: Build & package
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: '0'
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME}"
BIN="mythy"
[ "$GOOS" = windows ] && BIN="mythy.exe"
mkdir -p build dist
go build -trimpath \
-ldflags "-s -w -X main.version=${VERSION}" \
-o "build/${BIN}" \
./cmd/mythy
cp LICENSE THIRD_PARTY_LICENSES build/
ARCH="${GOARCH}"
[ -n "${GOARM:-}" ] && ARCH="armv${GOARM}"
STEM="mythy-${VERSION}-${GOOS}-${ARCH}"
if [ "$GOOS" = windows ]; then
(cd build && zip "../dist/${STEM}.zip" "$BIN" LICENSE THIRD_PARTY_LICENSES)
else
tar -C build -czf "dist/${STEM}.tar.gz" "$BIN" LICENSE THIRD_PARTY_LICENSES
fi
- uses: actions/upload-artifact@v7
with:
name: mythy-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}
path: dist/*
if-no-files-found: error
retention-days: 1
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Generate checksums
run: |
set -euo pipefail
cd dist
sha256sum * > SHA256SUMS
- uses: softprops/action-gh-release@v3
with:
files: dist/*
fail_on_unmatched_files: true
generate_release_notes: true