-
Notifications
You must be signed in to change notification settings - Fork 7
131 lines (111 loc) · 3.84 KB
/
release.yml
File metadata and controls
131 lines (111 loc) · 3.84 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
name: Release
on:
push:
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
jobs:
# Build binaries for all platforms
build:
name: Build ${{ matrix.target }}${{ matrix.suffix }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
cross: true
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross (for cross-compilation)
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build binary
shell: bash
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
- name: Prepare artifacts (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
VERSION="${GITHUB_REF#refs/tags/}"
BINARY="govctl"
ARCHIVE_NAME="govctl-${VERSION}-${{ matrix.target }}"
mkdir -p "dist/${ARCHIVE_NAME}"
cp "target/${{ matrix.target }}/release/${BINARY}" "dist/${ARCHIVE_NAME}/"
cp README.md LICENSE* "dist/${ARCHIVE_NAME}/" 2>/dev/null || true
cd dist
tar -czvf "${ARCHIVE_NAME}.tar.gz" "${ARCHIVE_NAME}"
echo "ASSET=${ARCHIVE_NAME}.tar.gz" >> $GITHUB_ENV
- name: Prepare artifacts (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$VERSION = $env:GITHUB_REF -replace 'refs/tags/', ''
$ARCHIVE_NAME = "govctl-${VERSION}-${{ matrix.target }}"
New-Item -ItemType Directory -Force -Path "dist\${ARCHIVE_NAME}"
Copy-Item "target\${{ matrix.target }}\release\govctl.exe" "dist\${ARCHIVE_NAME}\"
Copy-Item README.md, LICENSE* -Destination "dist\${ARCHIVE_NAME}\" -ErrorAction SilentlyContinue
Compress-Archive -Path "dist\${ARCHIVE_NAME}" -DestinationPath "dist\${ARCHIVE_NAME}.zip"
echo "ASSET=${ARCHIVE_NAME}.zip" >> $env:GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET }}
path: dist/${{ env.ASSET }}
retention-days: 1
# Create GitHub release with all artifacts
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
merge-multiple: true
- name: List artifacts
run: ls -la artifacts/
- name: Extract version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.VERSION }}
draft: false
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }}
generate_release_notes: true
body: |
TUI is now enabled by default in release binaries.
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}