Repository navigation
127 lines (112 loc) · 4.76 KB
/
Copy pathrelease.yml
File metadata and controls
127 lines (112 loc) · 4.76 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
name: release
# A `v*` tag builds `enowx` for every platform and publishes the archives as a
# GitHub release. Run it by hand to build without publishing.
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest }
- { target: aarch64-unknown-linux-musl, os: ubuntu-24.04-arm }
- { target: x86_64-apple-darwin, os: macos-latest }
- { target: aarch64-apple-darwin, os: macos-latest }
- { target: x86_64-pc-windows-msvc, os: windows-latest }
- { target: aarch64-pc-windows-msvc, os: windows-11-arm }
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install musl tools
if: contains(matrix.target, 'musl')
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }} -p enowx-cli
- name: Package (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
name=enowx-${{ matrix.target }}
mkdir "$name"
cp target/${{ matrix.target }}/release/enowx README.md LICENSE NOTICE "$name"/
tar czf "$name.tar.gz" "$name"
shasum -a 256 "$name.tar.gz" > "$name.tar.gz.sha256"
# The archive `enx update` and `enowx update` from v0.2.1 and v0.2.2
# ask for: the same binary under both names, so either updater
# brings its install to this release.
legacy=enx-${{ matrix.target }}
mkdir "$legacy"
cp target/${{ matrix.target }}/release/enowx "$legacy"/enowx
cp target/${{ matrix.target }}/release/enowx "$legacy"/enx
tar czf "$legacy.tar.gz" "$legacy"
shasum -a 256 "$legacy.tar.gz" > "$legacy.tar.gz.sha256"
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$name = "enowx-${{ matrix.target }}"
New-Item -ItemType Directory $name | Out-Null
Copy-Item target/${{ matrix.target }}/release/enowx.exe, README.md, LICENSE, NOTICE $name
Compress-Archive -Path $name -DestinationPath "$name.zip"
(Get-FileHash "$name.zip" -Algorithm SHA256).Hash.ToLower() + " $name.zip" | Out-File -Encoding ascii "$name.zip.sha256"
# What the v0.2.1 and v0.2.2 updaters ask for: both names.
$legacy = "enx-${{ matrix.target }}"
New-Item -ItemType Directory $legacy | Out-Null
Copy-Item target/${{ matrix.target }}/release/enowx.exe (Join-Path $legacy "enowx.exe")
Copy-Item target/${{ matrix.target }}/release/enowx.exe (Join-Path $legacy "enx.exe")
Compress-Archive -Path $legacy -DestinationPath "$legacy.zip"
(Get-FileHash "$legacy.zip" -Algorithm SHA256).Hash.ToLower() + " $legacy.zip" | Out-File -Encoding ascii "$legacy.zip.sha256"
- uses: actions/upload-artifact@v4
with:
name: enowx-${{ matrix.target }}
path: |
enowx-${{ matrix.target }}.tar.gz*
enowx-${{ matrix.target }}.zip*
enx-${{ matrix.target }}.tar.gz*
enx-${{ matrix.target }}.zip*
release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
# The release notes are this version's section of CHANGELOG.md, under
# the install lines, so the page says what changed in our own words.
- name: Release notes from CHANGELOG.md
shell: bash
run: |
version="${GITHUB_REF_NAME}"
awk -v head="## ${version} " 'index($0, head) == 1 { on = 1; next } on && /^## / { exit } on { print }' CHANGELOG.md > section.md
{
echo "Install or update:"
echo "- macOS / Linux: \`curl -fsSL https://enowx.ai/install.sh | sh\`"
echo "- Windows (PowerShell): \`irm https://enowx.ai/install.ps1 | iex\`"
echo
echo "Each archive has a \`.sha256\` checksum beside it."
echo
cat section.md
} > notes.md
test -s section.md || { echo "no section for ${version} in CHANGELOG.md"; exit 1; }
- uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }} (early release)
body_path: notes.md
files: dist/*