-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (99 loc) · 2.83 KB
/
deployment.yml
File metadata and controls
113 lines (99 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: Deployment
run-name: ${{ inputs.tag_name }} / ${{ inputs.environment }}
on:
workflow_dispatch:
inputs:
tag_name:
description: "Release version (e.g. v1.0.0)"
required: true
type: string
environment:
description: "Deployment environment"
default: production
type: choice
options:
- production
- staging
platforms:
description: "Target platforms (comma-separated: linux,windows,macos)"
default: "linux,windows,macos"
type: string
release:
description: "Create GitHub Release"
type: boolean
default: true
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Validate tag format
run: |
if [[ ! "${{ inputs.tag_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Invalid tag format. Must be in the form v1.2.3"
exit 1
fi
build:
needs: validate
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, windows, macos]
steps:
- name: Skip platforms not requested
run: |
if [[ ! "${{ inputs.platforms }}" =~ "${{ matrix.os }}" ]]; then
echo "Skipping build for ${{ matrix.os }}"
exit 0
fi
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Set version tag
run: git tag ${{ inputs.tag_name }}
- name: Build binaries
run: |
mkdir -p dist
case "${{ matrix.os }}" in
linux)
GOOS=linux GOARCH=amd64 go build -o dist/cli-linux
;;
windows)
GOOS=windows GOARCH=amd64 go build -o dist/cli-windows.exe
;;
macos)
GOOS=darwin GOARCH=amd64 go build -o dist/cli-macos
;;
esac
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: dist/*
release:
needs: build
runs-on: ubuntu-latest
if: inputs.release
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Prepare release files
run: |
mkdir -p dist
cp -r linux/* dist/ 2>/dev/null || true
cp -r windows/* dist/ 2>/dev/null || true
cp -r macos/* dist/ 2>/dev/null || true
- name: Generate SHA256 checksums
run: |
cd dist
sha256sum * > checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag_name }}
name: "Release ${{ inputs.tag_name }}"
files: dist/*