-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (98 loc) · 4.08 KB
/
Copy pathpublish-deb.yml
File metadata and controls
107 lines (98 loc) · 4.08 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
name: Publish Debian packages
# Reusable workflow invoked by cargo-dist's release pipeline as a
# user_publish_job (see dist-workspace.toml `publish-jobs`).
#
# Packages the prebuilt linux-gnu binaries from the GitHub release
# into .deb files (amd64 + arm64) and uploads each as a release asset.
#
# Each arch is uploaded under two names: a versioned one
# (`qn_X.Y.Z_amd64.deb`) for pinning/archival, and a version-less one
# (`qn_amd64.deb`) that gives a stable canonical URL via GitHub's
# `releases/latest/download/<file>` redirect. The version lives in the
# package's control metadata, so apt/dpkg install the right version
# regardless of the filename.
#
# Users install via `apt install ./qn_amd64.deb` (or the versioned file).
# A hosted apt repo (aptly/reprepro + GPG) is out of scope.
on:
workflow_call:
inputs:
plan:
description: dist-manifest JSON for this announcement
required: true
type: string
# contents: write is needed for `gh release upload`. The caller
# (custom-publish-deb in release.yml) must grant this via
# dist-workspace.toml's github-custom-job-permissions block.
permissions:
contents: write
jobs:
publish:
# Must be ubuntu-24.04 (glibc 2.39) — taiki-e/install-action pulls a
# prebuilt cargo-deb that's linked against glibc 2.39, which won't
# load on the older ubuntu-22.04 runners (glibc 2.35).
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- rust_target: x86_64-unknown-linux-gnu
deb_arch: amd64
- rust_target: aarch64-unknown-linux-gnu
deb_arch: arm64
steps:
- uses: actions/checkout@v4
- name: Extract release tag from plan
id: meta
env:
PLAN: ${{ inputs.plan }}
run: |
tag=$(echo "$PLAN" | jq -r '.announcement_tag')
version=$(echo "$PLAN" | jq -r '.releases[0].app_version')
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Install cargo-deb
uses: taiki-e/install-action@v2
with:
tool: cargo-deb
- name: Download linux-gnu archive for ${{ matrix.deb_arch }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p downloads
gh release download "${{ steps.meta.outputs.tag }}" \
--pattern 'quicknode-cli-${{ matrix.rust_target }}.tar.xz' \
--dir downloads/
- name: Stage binary at target/${{ matrix.rust_target }}/release/qn
run: |
# cargo-deb --no-build --target X expects the binary at
# target/X/release/qn. Extract the prebuilt qn from the
# release tarball into that path.
mkdir -p target/${{ matrix.rust_target }}/release
tar -xJf downloads/quicknode-cli-${{ matrix.rust_target }}.tar.xz \
--strip-components=1 \
-C target/${{ matrix.rust_target }}/release \
--wildcards '*/qn'
chmod +x target/${{ matrix.rust_target }}/release/qn
file target/${{ matrix.rust_target }}/release/qn
- name: Build .deb
run: |
# --no-build: don't recompile, use the staged binary.
# --no-strip: cargo-dist already stripped the binary upstream.
# --target: tells cargo-deb where to find the binary AND
# what dpkg arch to label the package as.
cargo deb --no-build --no-strip \
--target ${{ matrix.rust_target }} \
--output qn_${{ steps.meta.outputs.version }}_${{ matrix.deb_arch }}.deb
# Canonical copy with a version-less name, so
# releases/latest/download/qn_<arch>.deb stays a stable URL.
cp qn_${{ steps.meta.outputs.version }}_${{ matrix.deb_arch }}.deb \
qn_${{ matrix.deb_arch }}.deb
- name: Upload .deb to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ steps.meta.outputs.tag }}" \
qn_${{ steps.meta.outputs.version }}_${{ matrix.deb_arch }}.deb \
qn_${{ matrix.deb_arch }}.deb \
--clobber