-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (93 loc) · 3.2 KB
/
release.yml
File metadata and controls
107 lines (93 loc) · 3.2 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
# .github/workflows/release.yml
name: Build and Release
on:
push:
tags:
- 'v*' # MUST BE INDENTED UNDER 'push:'
workflow_dispatch: {} # Allows manual triggering
permissions:
contents: write
jobs:
build:
name: Build on ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- name: Linux x64
os: ubuntu-latest
asset_suffix: linux-x64
archive_ext: tar.gz
- name: Windows x64
os: windows-latest
asset_suffix: windows-x64
archive_ext: zip
- name: macOS Intel
os: macos-13
asset_suffix: macos-intel
archive_ext: tar.gz
- name: macOS Apple Silicon
os: macos-latest
asset_suffix: macos-arm64
archive_ext: tar.gz
steps:
- name: Checkout repository code
uses: actions/checkout@v4
- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build with CMake
run: cmake --build build --config Release
- name: Prepare Artifacts for Upload
shell: bash
run: |
# Create a directory to hold the assets
mkdir dist
# Define the executable name and copy it to the 'dist' directory
EXECUTABLE_NAME="tim2dump"
if [[ "${{ runner.os }}" == "Windows" ]]; then
cp "build/Release/${EXECUTABLE_NAME}.exe" dist/
else
cp "build/${EXECUTABLE_NAME}" dist/
fi
# Determine version name for archive
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION="${{ github.ref_name }}"
elif [[ "${{ github.ref }}" == refs/heads/release-* ]]; then
VERSION="${{ github.ref_name }}"
else
VERSION="${{ github.sha }}"
VERSION="${VERSION:0:7}" # Use short SHA for non-release branches
fi
# Create the archive
ARCHIVE_NAME="tim2dump-${VERSION}-${{ matrix.platform.asset_suffix }}"
if [[ "${{ runner.os }}" == "Windows" ]]; then
cd dist && 7z a "../${ARCHIVE_NAME}.zip" * && cd ..
else
cd dist && tar -czf "../${ARCHIVE_NAME}.tar.gz" * && cd ..
fi
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: tim2dump-${{ matrix.platform.asset_suffix }}
path: "*.${{ matrix.platform.archive_ext }}"
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
# Create releases ONLY for version tags
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
generate_release_notes: true
files: |
artifacts/**/*.zip
artifacts/**/*.tar.gz