-
Notifications
You must be signed in to change notification settings - Fork 53
138 lines (114 loc) · 3.94 KB
/
Copy pathrelease.yml
File metadata and controls
138 lines (114 loc) · 3.94 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
136
137
138
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
verify:
name: Verify Release Candidate
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.26.7'
- name: Verify dependencies and generated module files
shell: bash
run: |
go mod verify
unformatted="$(git ls-files -z '*.go' | xargs -0 gofmt -l)"
test -z "${unformatted}"
go mod tidy
git diff --exit-code -- go.mod go.sum
- name: Run static analysis
run: |
go vet ./...
go run honnef.co/go/tools/cmd/staticcheck@v0.8.1 ./...
- name: Run tests with the race detector
run: go test -race ./...
- name: Scan reachable dependencies for vulnerabilities
run: go run golang.org/x/vuln/cmd/govulncheck@v1.7.0 ./...
release:
name: Build and Publish Release
runs-on: ubuntu-latest
needs: verify
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.26.7'
check-latest: true
- name: Build and Package Multi-Platform Binaries
env:
TAG_NAME: ${{ github.ref_name }}
run: |
mkdir -p dist
PLATFORMS=(
"linux/amd64"
"linux/arm64"
"linux/arm/7"
"linux/arm/6"
"linux/386"
"darwin/amd64"
"darwin/arm64"
"windows/amd64"
"windows/arm64"
"windows/386"
"freebsd/amd64"
)
for PLATFORM in "${PLATFORMS[@]}"; do
IFS="/" read -r OS ARCH EXTRA <<< "${PLATFORM}"
BIN_NAME="transmission-telegram"
ARCHIVE_NAME="transmission-telegram_${TAG_NAME}_${OS}_${ARCH}"
export GOOS=${OS}
export GOARCH=${ARCH}
export CGO_ENABLED=0
if [ -n "${EXTRA}" ]; then
export GOARM=${EXTRA}
ARCHIVE_NAME="transmission-telegram_${TAG_NAME}_${OS}_${ARCH}v${EXTRA}"
else
unset GOARM
fi
BUILD_DIR="build_${OS}_${ARCH}${EXTRA}"
mkdir -p "${BUILD_DIR}"
TARGET_BIN="${BUILD_DIR}/${BIN_NAME}"
if [ "${OS}" = "windows" ]; then
TARGET_BIN="${TARGET_BIN}.exe"
fi
echo "Building ${OS}/${ARCH}${EXTRA}..."
go build -trimpath -ldflags="-s -w -X github.com/pyed/transmission-telegram/internal/config.Version=${TAG_NAME}" -o "${TARGET_BIN}" ./cmd/bot/
cp README.md LICENSE "${BUILD_DIR}/"
if [ "${OS}" = "windows" ]; then
(cd "${BUILD_DIR}" && zip -r "../dist/${ARCHIVE_NAME}.zip" .)
else
tar -czf "dist/${ARCHIVE_NAME}.tar.gz" -C "${BUILD_DIR}" .
fi
rm -rf "${BUILD_DIR}"
done
# Generate SHA-256 Checksums
cd dist
sha256sum * > "checksums.txt"
cd ..
- name: Create GitHub Release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
files: |
dist/*.tar.gz
dist/*.zip
dist/checksums.txt
generate_release_notes: true
draft: false
prerelease: false