Repository navigation
142 lines (128 loc) · 3.5 KB
/
Copy pathrelease.yml
File metadata and controls
142 lines (128 loc) · 3.5 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
139
140
141
142
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release version, for example v0.1.0"
required: true
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
metadata:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Resolve version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
version="${{ inputs.version }}"
else
version="${GITHUB_REF_NAME}"
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.22.x"
cache: false
- name: Verify
run: |
gofmt -l . | tee /tmp/gofmt.txt
test ! -s /tmp/gofmt.txt
go test ./...
go vet ./...
build:
name: Build ${{ matrix.asset }}
needs:
- metadata
- verify
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: linux/amd64
asset: linux_amd64
- target: linux/arm64
asset: linux_arm64
- target: linux/arm/v7
asset: linux_arm_v7
- target: darwin/amd64
asset: darwin_amd64
- target: darwin/arm64
asset: darwin_arm64
- target: windows/amd64
asset: windows_amd64
- target: windows/arm64
asset: windows_arm64
- target: freebsd/amd64
asset: freebsd_amd64
- target: freebsd/arm64
asset: freebsd_arm64
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.22.x"
cache: false
- name: Build target
env:
TARGETS: ${{ matrix.target }}
CHECKSUMS: "false"
VERSION: ${{ needs.metadata.outputs.version }}
COMMIT: ${{ github.sha }}
run: ./scripts/build-release.sh
- name: Upload target artifact
uses: actions/upload-artifact@v7
with:
name: opencode2api-${{ needs.metadata.outputs.version }}-${{ matrix.asset }}
path: dist/*.tar.gz
if-no-files-found: error
publish:
name: Publish GitHub Release
needs:
- metadata
- build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download target artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Generate checksums
run: |
cd dist
sha256sum ./*.tar.gz > checksums.txt
ls -lh
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.metadata.outputs.version }}
run: |
if gh release view "$VERSION" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release upload "$VERSION" dist/* --repo "$GITHUB_REPOSITORY" --clobber
else
gh release create "$VERSION" dist/* \
--repo "$GITHUB_REPOSITORY" \
--title "opencode2api $VERSION" \
--target "$GITHUB_SHA" \
--generate-notes
fi