-
-
Notifications
You must be signed in to change notification settings - Fork 86
137 lines (118 loc) · 5 KB
/
Copy pathpackaging.yaml
File metadata and controls
137 lines (118 loc) · 5 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
name: packaging
permissions: {}
on:
push:
branches:
- 'release/**'
workflow_dispatch:
jobs:
package:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu
steps:
- name: Setup packaging tools for cross compiled artifacts
run: |
sudo apt install --update musl-tools qemu-user-static crossbuild-essential-armhf crossbuild-essential-arm64 crossbuild-essential-i386
- name: Install toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: "stable"
components: "llvm-tools"
- name: Install cross, cargo-deb and cargo-generate-rpm
uses: taiki-e/install-action@43aecc8d72668fbcfe75c31400bc4f890f1c5853
with:
tool: cross, cargo-deb, cargo-generate-rpm
- name: Checkout sources
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
persist-credentials: false
- name: Build the release binaries
run: RELEASE_TARGETS="${{ matrix.target }}" utils/build-release.sh
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release-binaries-${{ matrix.target }}
path: target/pkg/
if-no-files-found: error
gather:
needs: package
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: release-binaries-*
path: target/pkg/
merge-multiple: true
- name: Create a SHA256SUMS file
run: |
cd target/pkg/
rm -rf SHA256SUMS
sha256sum -b * > SHA256SUMS
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release-binaries
path: target/pkg/
if-no-files-found: error
checks:
uses: './.github/workflows/checks.yaml'
release:
needs: [gather, checks]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/heads/release/') }}
permissions:
# This part of the release pipeline needs to create a tag and a release
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: release-binaries
path: target/pkg/
- name: Install toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: "stable"
components: "llvm-tools"
- name: Check that the release commit is verified
env:
GH_TOKEN: ${{ github.token }}
run: |
test "$(gh api "repos/${{ github.repository }}/commits/${{ github.sha }}" --jq .commit.verification.verified)" == "true"
- name: Read the version from the manifest file
run: echo "release_version=$(cargo read-manifest --manifest-path ntpd/Cargo.toml | jq -r .version)" >> "$GITHUB_ENV"
- name: Version in Cargo.toml must match the branch name
run: test "release/$release_version" == "${{ github.ref_name }}" # zizmor: ignore[template-injection] attacker can't push to arbitrary branch on our repo
- name: Ensure there is not already a released tag with a non-draft release
run: test "$(gh release view "v$release_version" --json isDraft --jq .isDraft 2>/dev/null || echo "true")" == "true"
- name: Verify that the changelog top most entry concerns this release
run: |
release_notes="$(awk '/^## / && !found { found=1; print; next } /^## / && found { exit } found { print }' CHANGELOG.md)"
release_notes_header="$(echo "$release_notes" | head -1)"
echo "Found release notes for '$release_notes_header'"
release_notes_body="$(echo "$release_notes" | tail +2)"
release_notes_body="${release_notes_body#"${release_notes_body%%[![:space:]]*}"}"
release_notes_body="${release_notes_body%"${release_notes_body##*[![:space:]]}"}"
release_notes_version="$(echo "$release_notes_header" | cut -d' ' -f2 | sed 's/[][]//g')"
echo "Found version '$release_notes_version' in release notes"
test "$release_notes_version" == "${release_version}"
echo "$release_notes_body" > release_notes.md
- name: Create a draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${release_version}" --draft \
--target "${{ github.sha }}" \
--title "Version ${release_version}" \
--notes-file release_notes.md target/pkg/*