Skip to content

Commit 4bf25b6

Browse files
committed
ci: fix auto release
1 parent 91c20b6 commit 4bf25b6

File tree

3 files changed

+89
-198
lines changed

3 files changed

+89
-198
lines changed

.github/workflows/release.yml

+83-184
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ jobs:
2323
uses: actions/checkout@v4
2424
- name: Get the release version from the tag
2525
if: env.VERSION == ''
26-
run: echo "VERSION=$(echo ${{ github.ref_name }} | sed 's/v\(.*\)-.*/\1/')" >> $GITHUB_ENV
26+
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
2727
- name: Show the version
2828
run: |
2929
echo "version is: $VERSION"
3030
- name: Check that tag version and Cargo.toml version are the same
3131
shell: bash
3232
run: |
33-
if ! grep -q "version = \"$VERSION\"" Cargo.toml; then
33+
if ! grep -q "version = \"$(echo $VERSION | sed 's/v\(.*\)-.*/\1/')\"" Cargo.toml; then
3434
echo "version does not match Cargo.toml" >&2
3535
exit 1
3636
fi
3737
- name: Create GitHub release
3838
env:
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
run: gh release create v$VERSION --verify-tag --draft --title $VERSION
40+
run: gh release create $VERSION --verify-tag --draft --title $VERSION
4141
outputs:
4242
version: ${{ env.VERSION }}
4343

@@ -70,135 +70,95 @@ jobs:
7070
rust: nightly
7171
target: x86_64-unknown-linux-musl
7272
strip: x86_64-linux-musl-strip
73-
- build: stable-x86
74-
os: ubuntu-latest
75-
rust: stable
76-
target: i686-unknown-linux-gnu
77-
strip: x86_64-linux-gnu-strip
78-
qemu: i386
79-
- build: stable-aarch64
80-
os: ubuntu-latest
81-
rust: stable
82-
target: aarch64-unknown-linux-gnu
83-
strip: aarch64-linux-gnu-strip
84-
qemu: qemu-aarch64
85-
- build: stable-arm-gnueabihf
86-
os: ubuntu-latest
87-
rust: stable
88-
target: armv7-unknown-linux-gnueabihf
89-
strip: arm-linux-gnueabihf-strip
90-
qemu: qemu-arm
91-
- build: stable-arm-musleabihf
92-
os: ubuntu-latest
93-
rust: stable
94-
target: armv7-unknown-linux-musleabihf
95-
strip: arm-linux-musleabihf-strip
96-
qemu: qemu-arm
97-
- build: stable-arm-musleabi
98-
os: ubuntu-latest
99-
rust: stable
100-
target: armv7-unknown-linux-musleabi
101-
strip: arm-linux-musleabi-strip
102-
qemu: qemu-arm
103-
- build: stable-powerpc64
104-
os: ubuntu-latest
105-
rust: stable
106-
target: powerpc64-unknown-linux-gnu
107-
strip: powerpc64-linux-gnu-strip
108-
qemu: qemu-ppc64
109-
- build: stable-s390x
110-
os: ubuntu-latest
111-
rust: stable
112-
target: s390x-unknown-linux-gnu
113-
strip: s390x-linux-gnu-strip
114-
qemu: qemu-s390x
115-
- build: macos
116-
os: macos-latest
117-
rust: nightly
118-
target: x86_64-apple-darwin
119-
- build: win-msvc
120-
os: windows-latest
121-
rust: nightly
122-
target: x86_64-pc-windows-msvc
123-
- build: win-gnu
124-
os: windows-latest
125-
rust: nightly-x86_64-gnu
126-
target: x86_64-pc-windows-gnu
127-
- build: win32-msvc
128-
os: windows-latest
129-
rust: nightly
130-
target: i686-pc-windows-msvc
73+
# - build: stable-x86
74+
# os: ubuntu-latest
75+
# rust: stable
76+
# target: i686-unknown-linux-gnu
77+
# strip: x86_64-linux-gnu-strip
78+
# qemu: i386
79+
# - build: stable-aarch64
80+
# os: ubuntu-latest
81+
# rust: stable
82+
# target: aarch64-unknown-linux-gnu
83+
# strip: aarch64-linux-gnu-strip
84+
# qemu: qemu-aarch64
85+
# - build: stable-arm-gnueabihf
86+
# os: ubuntu-latest
87+
# rust: stable
88+
# target: armv7-unknown-linux-gnueabihf
89+
# strip: arm-linux-gnueabihf-strip
90+
# qemu: qemu-arm
91+
# - build: stable-arm-musleabihf
92+
# os: ubuntu-latest
93+
# rust: stable
94+
# target: armv7-unknown-linux-musleabihf
95+
# strip: arm-linux-musleabihf-strip
96+
# qemu: qemu-arm
97+
# - build: stable-arm-musleabi
98+
# os: ubuntu-latest
99+
# rust: stable
100+
# target: armv7-unknown-linux-musleabi
101+
# strip: arm-linux-musleabi-strip
102+
# qemu: qemu-arm
103+
# - build: stable-powerpc64
104+
# os: ubuntu-latest
105+
# rust: stable
106+
# target: powerpc64-unknown-linux-gnu
107+
# strip: powerpc64-linux-gnu-strip
108+
# qemu: qemu-ppc64
109+
# - build: stable-s390x
110+
# os: ubuntu-latest
111+
# rust: stable
112+
# target: s390x-unknown-linux-gnu
113+
# strip: s390x-linux-gnu-strip
114+
# qemu: qemu-s390x
115+
# - build: macos
116+
# os: macos-latest
117+
# rust: nightly
118+
# target: x86_64-apple-darwin
119+
# - build: win-msvc
120+
# os: windows-latest
121+
# rust: nightly
122+
# target: x86_64-pc-windows-msvc
123+
# - build: win-gnu
124+
# os: windows-latest
125+
# rust: nightly-x86_64-gnu
126+
# target: x86_64-pc-windows-gnu
127+
# - build: win32-msvc
128+
# os: windows-latest
129+
# rust: nightly
130+
# target: i686-pc-windows-msvc
131131

132132
steps:
133133
- name: Checkout the repo
134134
uses: actions/checkout@v4
135135

136-
- name: Install packages (Ubuntu)
137-
if: matrix.os == 'ubuntu-latest'
138-
shell: bash
139-
run: |
140-
ci/ubuntu-install-packages
141-
142136
- name: Install Rust
143137
uses: dtolnay/rust-toolchain@master
144138
with:
145139
toolchain: ${{ matrix.rust }}
146140
target: ${{ matrix.target }}
147141

148-
- name: Use Cross
149-
if: matrix.os == 'ubuntu-latest' && matrix.target != ''
150-
shell: bash
151-
run: |
152-
# In the past, new releases of 'cross' have broken CI. So for now, we
153-
# pin it. We also use their pre-compiled binary releases because cross
154-
# has over 100 dependencies and takes a bit to compile.
155-
dir="$RUNNER_TEMP/cross-download"
156-
mkdir "$dir"
157-
echo "$dir" >> $GITHUB_PATH
158-
cd "$dir"
159-
curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz"
160-
tar xf cross-x86_64-unknown-linux-musl.tar.gz
161-
echo "CARGO=cross" >> $GITHUB_ENV
162-
163-
- name: Set target variables
164-
shell: bash
165-
run: |
166-
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
167-
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
168-
169-
- name: Show command used for Cargo
170-
shell: bash
171-
run: |
172-
echo "cargo command is: ${{ env.CARGO }}"
173-
echo "target flag is: ${{ env.TARGET_FLAGS }}"
174-
echo "target dir is: ${{ env.TARGET_DIR }}"
142+
- uses: actions-rs/cargo@v1
143+
with:
144+
use-cross: true
145+
command: build
146+
args: --verbose --release --locked --target ${{ matrix.target }}
175147

176-
- name: Build release binary
148+
- name: Set the release env variables
177149
shell: bash
178150
run: |
179-
${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
180151
if [ "${{ matrix.os }}" = "windows-latest" ]; then
181152
bin="target/${{ matrix.target }}/release/afrim-wish.exe"
182153
else
183154
bin="target/${{ matrix.target }}/release/afrim-wish"
184155
fi
185156
echo "BIN=$bin" >> $GITHUB_ENV
186157
187-
- name: Strip release binary (macos)
188-
if: matrix.os == 'macos-latest'
158+
- name: Strip release binary
189159
shell: bash
190160
run: strip "$BIN"
191161

192-
- name: Strip release binary (cross)
193-
if: env.CARGO == 'cross'
194-
shell: bash
195-
run: |
196-
docker run --rm -v \
197-
"$PWD/target:/target:Z" \
198-
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
199-
"${{ matrix.strip }}" \
200-
"/$BIN"
201-
202162
- name: Determine archive name
203163
shell: bash
204164
run: |
@@ -208,10 +168,22 @@ jobs:
208168
- name: Creating directory for archive
209169
shell: bash
210170
run: |
211-
mkdir -p "$ARCHIVE"/{complete,doc}
171+
mkdir -p "$ARCHIVE"
212172
cp "$BIN" "$ARCHIVE"/
213-
cp {README.md,LICENSE,demo.gif} "$ARCHIVE"/
214-
cp {CHANGELOG.md} "$ARCHIVE"/doc/
173+
cp {README.md,LICENSE,demo.gif,CHANGELOG.md} "$ARCHIVE"/
174+
175+
- uses: actions/checkout@v4
176+
with:
177+
repository: pythonbrad/afrim-man
178+
fetch-depth: 1
179+
path: afrim-man
180+
181+
- name: Build and Add documentation
182+
shell: bash
183+
run: |
184+
${{ env.CARGO }} install mdbook
185+
mdbook build afrim-man
186+
cp -r afrim-man/book "$ARCHIVE"/
215187
216188
- name: Build archive (Windows)
217189
shell: bash
@@ -238,76 +210,3 @@ jobs:
238210
run: |
239211
version="${{ needs.create-release.outputs.version }}"
240212
gh release upload "$version" ${{ env.ASSET }} ${{ env.ASSET_SUM }}
241-
242-
build-release-deb:
243-
name: build-release-deb
244-
needs: ["create-release"]
245-
runs-on: ubuntu-latest
246-
env:
247-
TARGET: x86_64-unknown-linux-musl
248-
# Emit backtraces on panics.
249-
RUST_BACKTRACE: 1
250-
251-
steps:
252-
- name: Checkout the repo
253-
uses: actions/checkout@v4
254-
255-
- name: Install packages (Ubuntu)
256-
shell: bash
257-
run: |
258-
ci/ubuntu-install-packages
259-
260-
- name: Install Rust
261-
uses: dtolnay/rust-toolchain@master
262-
with:
263-
toolchain: nightly
264-
target: ${{ env.TARGET }}
265-
266-
- name: Install cargo-deb
267-
shell: bash
268-
run: |
269-
cargo install cargo-deb
270-
271-
# 'cargo deb' does not seem to provide a way to specify an asset that is
272-
# created at build time, such as afrim-wish's man page. To work around this,
273-
# we force a debug build, copy out the man page (and shell completions)
274-
# produced from that build, put it into a predictable location and then
275-
# build the deb, which knows where to look.
276-
- name: Build debug binary to create release assets
277-
shell: bash
278-
run: |
279-
cargo build --target ${{ env.TARGET }}
280-
bin="target/${{ env.TARGET }}/debug/afrim-wish"
281-
echo "BIN=$bin" >> $GITHUB_ENV
282-
283-
- name: Create deployment directory
284-
shell: bash
285-
run: |
286-
dir=deployment/deb
287-
mkdir -p "$dir"
288-
echo "DEPLOY_DIR=$dir" >> $GITHUB_ENV
289-
290-
- name: Build release binary
291-
shell: bash
292-
run: |
293-
cargo deb --profile deb --target ${{ env.TARGET }}
294-
version="${{ needs.create-release.outputs.version }}"
295-
echo "DEB_DIR=target/${{ env.TARGET }}/debian" >> $GITHUB_ENV
296-
echo "DEB_NAME=afrim-wish-$version-1-amd64.deb" >> $GITHUB_ENV
297-
298-
- name: Create sha256 sum of deb file
299-
shell: bash
300-
run: |
301-
cd "$DEB_DIR"
302-
sum="$DEB_NAME.sha256"
303-
shasum -a 256 "$DEB_NAME" > "$sum"
304-
echo "SUM=$sum" >> $GITHUB_ENV
305-
306-
- name: Upload release archive
307-
env:
308-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
309-
shell: bash
310-
run: |
311-
cd "$DEB_DIR"
312-
version="${{ needs.create-release.outputs.version }}"
313-
gh release upload "$version" "$DEB_NAME" "$SUM"

Cross.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build]
2+
pre-build = [
3+
"dpkg --add-architecture $CROSS_DEB_ARCH",
4+
"apt-get update && apt-get install -y xorg-dev libxtst-dev libevdev-dev libxdo-dev xdo xdotool pkg-config"
5+
]
6+
env = { passthrough = ["PKG_CONFIG_ALLOW_CROSS=1"] }

ci/ubuntu-install-packages

-14
This file was deleted.

0 commit comments

Comments
 (0)