Repository navigation
176 lines (168 loc) · 6.16 KB
/
Copy pathrelease.yml
File metadata and controls
176 lines (168 loc) · 6.16 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
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Packages
on:
push:
branches: ["**"]
tags: ["**"]
workflow_dispatch:
inputs:
tag:
description: Existing version tag to publish; leave empty to test packaging only
required: false
type: string
permissions:
contents: read
concurrency:
group: release-assets-${{ inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
quality:
# Branch pushes already run these checks in the CI workflow.
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && inputs.tag != '')
uses: ./.github/workflows/build.yml
with:
ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.sha }}
source:
runs-on: ubuntu-24.04
timeout-minutes: 10
outputs:
version: ${{ steps.source.outputs.version }}
epoch: ${{ steps.source.outputs.epoch }}
prerelease: ${{ steps.source.outputs.prerelease }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.sha }}
persist-credentials: false
- name: Validate versions and create source archive
id: source
env:
RELEASE_TAG: ${{ inputs.tag || (startsWith(github.ref, 'refs/tags/v') && github.ref_name) || '' }}
run: |
# On manual dispatch GITHUB_SHA describes the workflow branch, not the tag.
export GITHUB_SHA=$(git rev-parse HEAD)
packaging/source.sh dist
- uses: actions/upload-artifact@v7
with:
name: release-source
path: dist/*.tar.gz
if-no-files-found: error
native:
needs: source
name: ${{ matrix.target }} (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
runner: [ubuntu-24.04, ubuntu-24.04-arm]
target: [debian13, ubuntu2610, fedora45, opensuseleap161, archlinux]
exclude:
- target: archlinux
runner: ubuntu-24.04-arm
include:
- target: debian13
image: debian:13-slim
bootstrap: deb
format: deb
- target: ubuntu2610
image: ubuntu:26.10
bootstrap: deb
format: deb
- target: fedora45
image: registry.fedoraproject.org/fedora:45
bootstrap: rpm
format: rpm
- target: opensuseleap161
image: registry.opensuse.org/opensuse/leap:16.1
bootstrap: suse
format: rpm
- target: archlinux
image: archlinux:base-devel
bootstrap: arch
format: arch
steps:
- uses: actions/download-artifact@v8
with:
name: release-source
path: source-release
- uses: actions-rust-lang/setup-rust-toolchain@v2
with:
toolchain: stable
cache: false
- name: Build, install, reinstall, and remove in target distribution
env:
VERSION: ${{ needs.source.outputs.version }}
SOURCE_DATE_EPOCH: ${{ needs.source.outputs.epoch }}
BUILD_FLAVOR: ${{ matrix.target }}
IMAGE: ${{ matrix.image }}
BOOTSTRAP: ${{ matrix.bootstrap }}
FORMAT: ${{ matrix.format }}
run: |
mkdir -p packages
toolchain=$(rustc --print sysroot)
docker run --rm \
-e VERSION -e SOURCE_DATE_EPOCH -e BUILD_FLAVOR -e BOOTSTRAP -e FORMAT \
-v "$PWD/source-release:/release:ro" -v "$PWD/packages:/output" \
-v "$toolchain:/opt/rust:ro" "$IMAGE" sh -eu -c '
mkdir -p /build/source
tar -xzf "/release/backlightd-$VERSION.tar.gz" --strip-components=1 -C /build/source
cd /build/source
bash packaging/container-build.sh "$BOOTSTRAP" "$FORMAT" "/release/backlightd-$VERSION.tar.gz"
'
- uses: actions/upload-artifact@v7
with:
name: package-${{ matrix.target }}-${{ matrix.runner }}
path: packages/*
if-no-files-found: error
compression-level: 0
nix:
needs: source
name: Nix (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
runner: [ubuntu-24.04, ubuntu-24.04-arm]
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.sha }}
persist-credentials: false
- uses: cachix/install-nix-action@v31
- name: Build package and check NixOS module
run: nix flake check --no-update-lock-file --print-build-logs
publish:
# Packaging runs on every push; only version tags or explicit tagged dispatches publish.
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && inputs.tag != '')
needs: [quality, source, native, nix]
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Publish complete release with checksums
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ inputs.tag || (startsWith(github.ref, 'refs/tags/v') && github.ref_name) || '' }}
VERSION: ${{ needs.source.outputs.version }}
PRERELEASE: ${{ needs.source.outputs.prerelease }}
run: |
cd dist
sha256sum ./* > SHA256SUMS
if gh release view "$RELEASE_TAG" --json isDraft --jq .isDraft > /tmp/release-is-draft 2>/dev/null; then
test "$(cat /tmp/release-is-draft)" = true || {
echo 'Refusing to replace an already published release.' >&2
exit 1
}
else
gh release create "$RELEASE_TAG" --verify-tag --draft \
--title "backlightd $VERSION" --generate-notes
fi
gh release upload "$RELEASE_TAG" ./* --clobber
gh release edit "$RELEASE_TAG" --draft=false --prerelease="$PRERELEASE"