-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (101 loc) · 2.83 KB
/
release.yml
File metadata and controls
113 lines (101 loc) · 2.83 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
name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag, e.g. v0.1.0"
required: true
type: string
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve tag
id: tag
run: |
set -euo pipefail
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
if [[ -z "${TAG}" ]]; then
echo "tag is empty" >&2
exit 1
fi
echo "tag=${TAG}" >> "${GITHUB_OUTPUT}"
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build binary
env:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
set -euo pipefail
mkdir -p dist
OUT="dist/codewithphone"
go build -trimpath -ldflags="-s -w" -o "${OUT}" ./cmd/codewithphone
TAR="dist/codewithphone_${{ steps.tag.outputs.tag }}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz"
tar -C dist -czf "${TAR}" codewithphone
rm -f "${OUT}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*.tar.gz
publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve tag
id: tag
run: |
set -euo pipefail
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "tag=${TAG}" >> "${GITHUB_OUTPUT}"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Flatten artifacts and generate checksums
run: |
set -euo pipefail
mkdir -p release
find dist -type f -name "*.tar.gz" -exec mv {} release/ \;
(cd release && sha256sum *.tar.gz > checksums.txt)
ls -la release
- name: Create or update release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
generate_release_notes: true
files: |
release/*.tar.gz
release/checksums.txt