-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (78 loc) · 2.31 KB
/
Copy pathrelease.yml
File metadata and controls
89 lines (78 loc) · 2.31 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag to create or update"
required: true
type: string
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
runner: ubuntu-24.04
cgo: "0"
- goos: linux
goarch: arm64
runner: ubuntu-24.04-arm
cgo: "0"
- goos: darwin
goarch: amd64
runner: macos-15-intel
cgo: "1"
- goos: darwin
goarch: arm64
runner: macos-14
cgo: "1"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: ${{ matrix.cgo }}
run: go build -trimpath -ldflags="-s -w" -o opub .
- name: Package
run: tar -czf "opub-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz" opub
- uses: actions/upload-artifact@v4
with:
name: opub-${{ matrix.goos }}-${{ matrix.goarch }}
path: opub-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
if-no-files-found: error
release:
name: Publish release
runs-on: ubuntu-24.04
needs: build
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.event.inputs.tag || github.ref_name }}
steps:
- uses: actions/download-artifact@v4
with:
pattern: opub-*
path: dist
merge-multiple: true
- name: Generate checksums
working-directory: dist
run: sha256sum opub-*.tar.gz > SHA256SUMS
- name: Create or update release
run: |
if gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" dist/opub-*.tar.gz dist/SHA256SUMS --clobber --repo "$GITHUB_REPOSITORY"
else
gh release create "$RELEASE_TAG" dist/opub-*.tar.gz dist/SHA256SUMS --title "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY"
fi