forked from flynn/flynn
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (100 loc) · 2.97 KB
/
Copy pathrelease-cli.yml
File metadata and controls
114 lines (100 loc) · 2.97 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
# Release workflow for Flynn CLI
#
# Triggered when a tag matching "v*" is pushed. Builds the flynn CLI binary
# for five platforms and creates a GitHub release with gzipped binaries.
#
# Version is derived from the tag name (e.g. v20260503.0).
name: Release CLI
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Version tag (e.g. v20260503.0)'
required: true
permissions:
contents: write
jobs:
build:
name: Build CLI (${{ matrix.goos }}/${{ matrix.goarch }})
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
fi
- name: Build CLI
env:
CGO_ENABLED: '0'
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
VERSION="${{ steps.version.outputs.version }}"
EXT=""
if [ "${{ matrix.goos }}" = "windows" ]; then
EXT=".exe"
fi
OUTFILE="flynn-cli-${{ matrix.goos }}-${{ matrix.goarch }}${EXT}"
go build \
-ldflags "-s -w -X github.com/flynn/flynn/pkg/version.version=${VERSION}" \
-o "${OUTFILE}" \
./cli
gzip -k "${OUTFILE}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: flynn-cli-${{ matrix.goos }}-${{ matrix.goarch }}
path: flynn-cli-*
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
fi
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: List artifacts
run: ls -lR artifacts/
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
generate_release_notes: true
files: |
artifacts/flynn-cli-*.gz