Repository navigation
128 lines (116 loc) · 4.34 KB
/
Copy pathrelease.yml
File metadata and controls
128 lines (116 loc) · 4.34 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
name: Release
# Build all three artifacts in parallel and publish a draft release.
# Triggers:
# * pushing a tag matching v*
# * manual run (workflow_dispatch) with a `tag` input — the tag is created
# from the current commit and then used exactly as a pushed tag would be.
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Version tag to create and release (e.g. v0.1.0)"
required: true
type: string
permissions:
contents: write
jobs:
# ── Resolve (and on manual dispatch, create) the release tag ──────────────
prepare:
runs-on: ubuntu-24.04
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "$TAG"
git push origin "$TAG"
else
TAG="${{ github.ref_name }}"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
# ── Linux + Windows build concurrently ────────────────────────────────────
build:
needs: prepare
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
target: [linux, windows]
steps:
- uses: actions/checkout@v4
# Only the deps each target actually needs (smaller = faster).
- name: Install dependencies (Linux build)
if: matrix.target == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
pkg-config libudev-dev libxkbcommon-dev libxkbcommon-x11-dev \
libwayland-dev libxcb1-dev libfontconfig1-dev
- name: Install dependencies (Windows build)
if: matrix.target == 'windows'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends mingw-w64 nsis
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target == 'windows' && 'x86_64-pc-windows-gnu' || '' }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
cache-all-crates: true
- name: Build (Linux)
if: matrix.target == 'linux'
run: |
cargo build --release
mkdir -p dist
cp target/release/slidr dist/Slidr-linux-x86_64
# Ships alongside the binary: without this rule the serial device is
# root-only on most distributions, and someone who downloaded the
# binary (rather than cloning) has no way to get at the file.
cp packaging/99-slidr.rules dist/99-slidr.rules
- name: Build (Windows + interactive installer)
if: matrix.target == 'windows'
run: |
VERSION="${{ needs.prepare.outputs.tag }}"; VERSION="${VERSION#v}"
cargo build --release --target x86_64-pc-windows-gnu
cp target/x86_64-pc-windows-gnu/release/slidr.exe installer/slidr.exe
cp assets/logo.ico installer/logo.ico
(cd installer && makensis -DVERSION="$VERSION" slidr.nsi)
mkdir -p dist
cp target/x86_64-pc-windows-gnu/release/slidr.exe dist/Slidr-windows-portable.exe
cp installer/Slidr-windows-setup.exe dist/Slidr-windows-setup.exe
- uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.target }}
path: dist/*
retention-days: 1
# ── Collect artifacts and draft the release ───────────────────────────────
release:
needs: [prepare, build]
runs-on: ubuntu-24.04
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- run: ls -lh dist
- name: Create draft release
uses: softprops/action-gh-release@v2
with:
draft: true
name: "Slidr ${{ needs.prepare.outputs.tag }}"
tag_name: ${{ needs.prepare.outputs.tag }}
generate_release_notes: true
files: dist/*