-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (103 loc) · 3.07 KB
/
Copy pathwindows-executable.yml
File metadata and controls
121 lines (103 loc) · 3.07 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
name: Windows Executables
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: Existing release tag to build, for example v0.2.0
required: true
type: string
workflow_call:
inputs:
tag:
description: Existing release tag to build
required: true
type: string
permissions:
contents: write
concurrency:
group: windows-executable-${{ inputs.tag || github.ref }}
cancel-in-progress: false
env:
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout release tag
uses: actions/checkout@v7
with:
ref: ${{ env.RELEASE_TAG }}
- name: Setup Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
- name: Tests
run: go test ./...
build:
needs: validate
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- goarch: amd64
file: MCQuery.exe
artifact: MCQuery-windows-x64
- goarch: arm64
file: MCQuery-arm64.exe
artifact: MCQuery-windows-arm64
steps:
- name: Checkout release tag
uses: actions/checkout@v7
with:
ref: ${{ env.RELEASE_TAG }}
- name: Setup Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
- name: Build ${{ matrix.artifact }}
shell: pwsh
env:
GOOS: windows
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
$version = $env:RELEASE_TAG.TrimStart("v")
$versionSymbol = "UWP-TCP-Con/internal/cli.appVersion=$version"
go build -trimpath -ldflags "-s -w -X=$versionSymbol" -o "dist/${{ matrix.file }}" ./cmd/uwp-tcp-con
- name: Upload executable artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.file }}
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download Windows executables
uses: actions/download-artifact@v8
with:
pattern: MCQuery-windows-*
path: dist
merge-multiple: true
- name: Create checksums
working-directory: dist
run: sha256sum *.exe > SHA256SUMS.txt
- name: Ensure GitHub release exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if ! gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release create "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --verify-tag --generate-notes --title "$RELEASE_TAG"
fi
- name: Attach executables to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload "$RELEASE_TAG" dist/*.exe dist/SHA256SUMS.txt --repo "$GITHUB_REPOSITORY" --clobber