-
Notifications
You must be signed in to change notification settings - Fork 1.4k
188 lines (166 loc) · 6.04 KB
/
cd.yml
File metadata and controls
188 lines (166 loc) · 6.04 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
177
178
179
180
181
182
183
184
185
186
187
188
name: cd
# creates a draft release with srcs and binary products attached
on:
workflow_dispatch:
inputs:
version:
description: version *w/out* the v prefix
required: true
concurrency:
group: cd/${{ github.event.inputs.version }}
cancel-in-progress: true
jobs:
qa:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --all-features
env:
RUSTFLAGS: "-D warnings"
attach-srcs:
runs-on: ubuntu-latest
needs: qa
env:
FILENAME: pkgx-${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v6
with:
path: ${{ env.FILENAME }}
- name: clean
run: rm -rf ${{ env.FILENAME }}/.github .gitbook.yml
- name: include GPG pubkey
run: echo "${{ secrets.GPG_PUBLIC_KEY }}" | base64 -d > $FILENAME/pkgx.dev.pub.asc
- run: |
tar cJf $FILENAME.tar.xz $FILENAME
tar czf $FILENAME.tar.gz $FILENAME
- name: attach srcs to release
run: gh release upload --clobber
v${{ github.event.inputs.version }}
../$FILENAME.tar.xz
working-directory: ${{ env.FILENAME }}
env:
# using this token rather than github.token due to `release not found` bug
# https://github.com/pkgxdev/cli/issues/5252
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- uses: actions/upload-artifact@v7
with:
name: srcs
path: ${{ env.FILENAME }}.tar.gz
if-no-files-found: error
attach-binary-products:
needs: attach-srcs
permissions:
actions: write
strategy:
matrix:
platform:
- os: ["self-hosted", "macOS", "X64"]
build-id: darwin+x86-64
pkgs: gh
- os: ubuntu-latest
container: debian:buster-slim
build-id: linux+x86-64
pkgs: gh
- os: macos-latest
build-id: darwin+aarch64
- os: [self-hosted, linux, ARM64]
build-id: linux+aarch64
pkgs: llvm.org perl gnu.org/make xz gh
- os: windows-latest
build-id: windows+x86-64
fail-fast: false
runs-on: ${{ matrix.platform.os }}
name: ${{ matrix.platform.build-id }}
container: ${{ matrix.platform.container }}
env:
BASENAME: pkgx-${{ github.event.inputs.version }}+${{ matrix.platform.build-id }}
steps:
- uses: actions/download-artifact@v8
with:
name: srcs
# debian:buster is archived, so we need to fix its sources.list
- name: fix debian:buster
if: ${{ matrix.platform.container == 'debian:buster-slim' }}
run: sed -i 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.list
- uses: pkgxdev/setup@v4
with:
+: ${{ matrix.platform.pkgs }}
- name: Prep
run: |
case ${{ matrix.platform.build-id }} in
linux+aarch64)
echo AR=llvm-ar >> $GITHUB_ENV;;
linux+x86-64)
apt-get update
apt-get install curl gcc perl-modules openssl make xz-utils --yes;;
darwin+aarch64)
# https://github.com/pkgxdev/pkgx/issues/1158
brew uninstall --ignore-dependencies xz
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV;;
esac
if: ${{ runner.os != 'Windows' }}
- name: Prep
if: ${{ runner.os == 'Windows' }}
run: Add-Content -Path $env:GITHUB_ENV -Value "EXT=.exe"
- run: tar xzf pkgx-${{ github.event.inputs.version }}.tar.gz --strip-components=1
- uses: dtolnay/rust-toolchain@stable
# hack to statically link libgcc
- run: |
echo '#!/bin/bash' > linkerdriver.wrap
echo 'exec "${CC:-cc}" "${@/-lgcc_s/-lgcc_eh}"' >> linkerdriver.wrap
chmod +x ./linkerdriver.wrap
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=$PWD/linkerdriver.wrap" >> $GITHUB_ENV
if: ${{ runner.os == 'Linux' }}
- run: |
cargo build --release
mv target/release/pkgx${{ env.EXT }} .
- run: strip ./pkgx
if: ${{ runner.os != 'Windows' }}
- uses: pkgxdev/pantry/.github/actions/setup@main
if: startsWith(matrix.platform.build-id, 'darwin+')
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE_P12 }}
p12-password: ${{ secrets.APPLE_CERTIFICATE_P12_PASSWORD }}
APPLE_IDENTITY: ${{ secrets.APPLE_IDENTITY }}
- run: codesign
--sign "$APPLE_IDENTITY" --force
--preserve-metadata=entitlements,requirements,flags,runtime ./pkgx
env:
APPLE_IDENTITY: ${{ secrets.APPLE_IDENTITY }}
if: startsWith(matrix.platform.build-id, 'darwin+')
- name: sanity check
run: test "$(./pkgx --version)" = "pkgx ${{ github.event.inputs.version }}"
- run: |
tar cJf $BASENAME.tar.xz pkgx
tar czf $BASENAME.tar.gz pkgx
if: ${{ runner.os != 'Windows' }}
- run: Compress-Archive -Path pkgx.exe -DestinationPath ${{env.BASENAME}}.zip
if: ${{ runner.os == 'Windows' }}
- name: GPG sign archives
run: |
./pkgx gpg-agent --daemon || true
echo $GPG_PRIVATE_KEY | \
base64 -d | \
./pkgx gpg --import --batch --yes
./pkgx gpg \
--detach-sign --armor \
--local-user $GPG_KEY_ID \
$BASENAME.tar.xz
env:
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
if: ${{ runner.os != 'Windows' }}
- name: attach product to release
run: gh release upload --clobber
v${{ github.event.inputs.version }}
${{env.BASENAME}}.*
env:
# using this token rather than github.token due to `release not found` bug
# https://github.com/pkgxdev/cli/issues/5252
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_REPO: pkgxdev/pkgx
shell: bash