Repository navigation
110 lines (103 loc) · 4.01 KB
/
Copy pathrelease.yml
File metadata and controls
110 lines (103 loc) · 4.01 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
# SPDX-License-Identifier: GPL-2.0-only
name: Release
# Publishes a GitHub Release (which the in-app updater checks) whenever a
# `v*` tag is pushed. Can also be run manually with an explicit version.
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description: "Version, e.g. 0.1.0 (creates tag v<version>)"
required: true
permissions:
contents: write # create releases + tags
env:
CARGO_TERM_COLOR: always
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.v.outputs.version }}
tag: ${{ steps.v.outputs.tag }}
steps:
- id: v
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
v="${{ github.event.inputs.version }}"
else
v="${GITHUB_REF_NAME#v}"
fi
echo "version=$v" >> "$GITHUB_OUTPUT"
echo "tag=v$v" >> "$GITHUB_OUTPUT"
windows:
needs: prepare
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
# Stamp the release version into the workspace so the built binary reports
# it via CARGO_PKG_VERSION (this is what the updater compares against).
- name: Stamp version
shell: bash
run: sed -i 's/^version = "[^"]*"/version = "${{ needs.prepare.outputs.version }}"/' Cargo.toml
- name: Build release binaries
run: cargo build --release --all-features --bins
- name: Install NSIS
run: choco install nsis -y --no-progress
- name: Build installer (NSIS)
shell: pwsh
run: |
# NSIS is not on PATH on the runner; call makensis by its install path.
# File/OutFile relative paths resolve against the .nsi's directory, so
# pass BINDIR and OUTFILE as absolute paths.
$makensis = "C:\Program Files (x86)\NSIS\makensis.exe"
$bindir = (Resolve-Path "target\release").Path
$outfile = Join-Path (Get-Location).Path "Modrix-Setup-${{ needs.prepare.outputs.version }}.exe"
Get-ChildItem "$bindir\*.exe" | Select-Object Name
& $makensis "-DVERSION=${{ needs.prepare.outputs.version }}" "-DBINDIR=$bindir" "-DOUTFILE=$outfile" installer\windows\modrix.nsi
if ($LASTEXITCODE -ne 0) { throw "makensis failed with exit code $LASTEXITCODE" }
if (-not (Test-Path $outfile)) { throw "installer not produced at $outfile" }
- name: Portable zip
shell: pwsh
run: Compress-Archive -Path target/release/modrix-gui.exe, target/release/modrix.exe, target/release/modrix-tui.exe -DestinationPath Modrix-windows-x86_64.zip
- uses: actions/upload-artifact@v4
with:
name: windows
path: |
Modrix-Setup-*.exe
Modrix-windows-x86_64.zip
linux:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Stamp version
run: sed -i 's/^version = "[^"]*"/version = "${{ needs.prepare.outputs.version }}"/' Cargo.toml
- name: Build release binaries
run: cargo build --release --all-features --bins
- name: Tarball
run: tar -C target/release -czf Modrix-linux-x86_64.tar.gz modrix-gui modrix modrix-tui
- uses: actions/upload-artifact@v4
with:
name: linux
path: Modrix-linux-x86_64.tar.gz
release:
needs: [prepare, windows, linux]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.tag }}
name: Modrix ${{ needs.prepare.outputs.version }}
# A semver pre-release (e.g. 0.1.0-beta.1) is flagged as a GitHub
# prerelease; the in-app updater only offers stable releases.
prerelease: ${{ contains(needs.prepare.outputs.version, '-') }}
generate_release_notes: true
files: dist/**/*