Repository navigation
163 lines (156 loc) · 6.28 KB
/
Copy pathrelease.yml
File metadata and controls
163 lines (156 loc) · 6.28 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Release binaries for a version tag.
#
# Pushing `v1.2.3` builds `incode` and `insbx` for every platform below, packs
# each pair as `incode-<target>.tar.gz` (`.zip` on Windows), and publishes them
# on a GitHub Release with a `SHA256SUMS` beside them. `scripts/install.sh`,
# `scripts/install.ps1` and `incode update` all read exactly these names, so a
# rename here is a rename there.
name: release
on:
push:
tags: ["v*"]
permissions:
contents: read
jobs:
# The tag must name the version the programs report. `incode update` compares
# its own version against the latest release's tag, so a binary that reports
# less than its tag (an rc built as plain `0.1.0`) would never see the final
# release as newer, and one that reports more would skip a real update.
version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Tag matches all three crates' versions
env:
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
want="${TAG#v}"
cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[] | select(.name == "incord-code" or .name == "incord-sandbox" or .name == "incord-desktop") | "\(.name) \(.version)"' \
> versions.txt
cat versions.txt
test "$(wc -l < versions.txt)" -eq 3
while read -r name version; do
if [ "$version" != "$want" ]; then
echo "::error::tag $TAG names version $want, but $name is $version in its Cargo.toml"
exit 1
fi
done < versions.txt
build:
name: build (${{ matrix.target }})
needs: version
strategy:
fail-fast: false
matrix:
include:
# The oldest supported Ubuntu, not the latest: the binary links the
# glibc it was built against, and an older one runs on more systems.
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
# A native ARM runner, so OpenSSL and the C the grammars compile
# need no cross toolchain.
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04-arm
# One macOS runner builds both: Xcode's SDK targets either arch.
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
# The same set ci.yml installs, and ci.yml's `release-build-linux` job
# builds the Linux legs below exactly as this does on every pull
# request — change the two together. The desktop backends (x11rb for
# capture and input, AT-SPI over zbus) are pure Rust and link no system
# library; pkg-config is how openssl-sys finds the runner's OpenSSL.
- name: Linux build dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends pkg-config
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }} -p incord-code -p incord-sandbox
# A flat archive: the two programs and the licence, no folder around
# them. `incode update` looks for the programs at the top.
#
# The files are NAMED rather than archived as `.`: a `./` entry names
# no file, and incode's unpacker refuses an archive that holds one.
# COPYFILE_DISABLE stops macOS tar adding `._*` metadata entries.
- name: Package (unix)
if: runner.os != 'Windows'
shell: bash
env:
COPYFILE_DISABLE: "1"
run: |
set -euo pipefail
stage="$(mktemp -d)"
bin="target/${{ matrix.target }}/release"
cp "$bin/incode" "$bin/insbx" LICENSE NOTICE README.md "$stage/"
mkdir -p dist
tar -C "$stage" -czf "dist/incode-${{ matrix.target }}.tar.gz" \
incode insbx LICENSE NOTICE README.md
- name: Package (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$stage = New-Item -ItemType Directory -Path (Join-Path $env:RUNNER_TEMP "stage")
$bin = "target/${{ matrix.target }}/release"
Copy-Item "$bin/incode.exe", "$bin/insbx.exe", LICENSE, NOTICE, README.md $stage
New-Item -ItemType Directory -Force -Path dist | Out-Null
Compress-Archive -Path (Join-Path $stage "*") -DestinationPath "dist/incode-${{ matrix.target }}.zip"
- uses: actions/upload-artifact@v4
with:
name: incode-${{ matrix.target }}
path: dist/*
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
pattern: incode-*
merge-multiple: true
# One line per archive, `<sha256> <name>` — the `sha256sum` format,
# which the installers and `incode update` parse.
- name: Checksums
working-directory: dist
run: |
sha256sum incode-* > SHA256SUMS
cat SHA256SUMS
- uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
# A tag with a hyphen (`v1.2.0-rc.1`) is a pre-release, which
# GitHub's `releases/latest` — and so every installer — skips.
prerelease: ${{ contains(github.ref_name, '-') }}
# What was just published, installed the way a user installs it on each
# platform, and checked to report this tag's version.
install-check:
needs: release
uses: ./.github/workflows/install-check.yml
with:
tag: ${{ github.ref_name }}
# The winget, Scoop and Homebrew manifests for this release, made from its
# SHA256SUMS and installed with on each platform; uploaded ready to submit.
# Release tags only: package managers do not offer pre-releases.
package-check:
needs: install-check
if: ${{ !contains(github.ref_name, '-') }}
uses: ./.github/workflows/package-check.yml
with:
tag: ${{ github.ref_name }}