Repository navigation
80 lines (74 loc) · 2.7 KB
/
Copy pathrelease.yml
File metadata and controls
80 lines (74 loc) · 2.7 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
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
rpm:
name: Fedora rpm
runs-on: ubuntu-latest
container: fedora:44
steps:
- uses: actions/checkout@v4
- name: Build tools
run: dnf install -y gcc rustup git rpm-build && rustup-init -y --profile minimal && echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- uses: taiki-e/install-action@v2
with:
tool: cargo-generate-rpm
- run: cargo build --release
- run: cargo generate-rpm -p crates/app && mkdir -p dist && cp target/generate-rpm/*.rpm dist/
- uses: actions/upload-artifact@v4
with:
name: rpm
path: dist/*.rpm
deb:
name: Debian deb
# Ubuntu 22.04 has glibc 2.35, so the package installs on Debian 12 and Ubuntu 22.04 or newer.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@v2
with:
tool: cargo-deb
- run: cargo build --release
- run: cargo deb -p re-code --no-build -o dist/
- uses: actions/upload-artifact@v4
with:
name: deb
path: dist/*.deb
publish:
name: Publish the release
needs: [rpm, deb]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Checksums and notes
run: |
cd dist && sha256sum *.rpm *.deb > SHA256SUMS && cd ..
version="${GITHUB_REF_NAME#v}"
# The CHANGELOG section for this version, up to the next heading.
awk -v v="$version" '
$0 ~ "^## \\[" v "\\]" { on = 1; next }
on && /^## \[/ { exit }
on { print }
' CHANGELOG.md > notes.md
if [ ! -s notes.md ]; then echo "See CHANGELOG.md." > notes.md; fi
printf '\n## Install\n\n```sh\nsudo dnf install ./re-code-%s-1.x86_64.rpm # Fedora\nsudo apt install ./re-code_%s-1_amd64.deb # Debian 12+, Ubuntu 22.04+\n```\n\nThe deb is built on Ubuntu 22.04 (glibc 2.35). `bubblewrap` is recommended. `SHA256SUMS` covers both packages.\n' "$version" "$version" >> notes.md
- name: Create or update the release
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" dist/* --clobber
gh release edit "$GITHUB_REF_NAME" --notes-file notes.md
else
gh release create "$GITHUB_REF_NAME" dist/* --title "re-code ${GITHUB_REF_NAME#v}" --notes-file notes.md
fi