-
-
Notifications
You must be signed in to change notification settings - Fork 5
94 lines (84 loc) · 2.94 KB
/
release.yml
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
# Upon a new tag being pushed to git, this workflow will:
# - Get the app version (from tag)
# - Draft a new release with release notes
# - Compile the Go binary for all platforms
# - Attach the compiled binaries to the release
name: 🏗️ Release Binaries
on:
push:
tags:
- '^[0-9]+\.[0-9]+\.[0-9]+$'
workflow_dispatch:
inputs:
tag:
description: 'Tag to draft a release for (must already exist)'
required: true
jobs:
create-draft-release:
name: Create Draft Release 1️⃣
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create_release.outputs.id }}
tag_name: ${{ steps.get_tag_name.outputs.tag_name }}
steps:
- name: Checkout code 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get Tag Name 🏷️
id: get_tag_name
run: echo "::set-output name=tag_name::${GITHUB_REF##*/}"
- name: Create Draft Release 📝
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
release_name: Release ${{ github.event.inputs.tag || github.ref_name }}
draft: true
prerelease: false
generate_release_notes: true
- name: Output new release URL ↗️
run: 'echo "Draft release URL: ${{ steps.create_release.outputs.html_url }}"'
compile-and-attach:
name: Compile and Attach Go Binary 2️⃣
needs: create-draft-release
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: ['386', amd64, arm64]
exclude:
- goarch: '386'
goos: darwin
- goarch: arm64
goos: windows
steps:
- name: Checkout code 🛎️
uses: actions/checkout@v3
- name: Set up Go 🏗️
uses: actions/setup-go@v2
with:
go-version: 1.22.4
- name: Compile Go binaries 🔨
run: |
go build -ldflags "-X main.Version=${{ needs.create-draft-release.outputs.tag_name }}" -o web-check-api .
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
- name: Upload Go binaries ⤴️
uses: actions/upload-artifact@v2
with:
name: web-check-api-${{ matrix.goos }}-${{ matrix.goarch }}
path: web-check-api
- name: Attach binaries to release 📎
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.create-draft-release.outputs.release_id }}
asset_path: web-check-api
asset_name: web-check-api-${{ matrix.goos }}-${{ matrix.goarch }}
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}