Skip to content

Commit

Permalink
ci: run armhf and arm64 build in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed Oct 25, 2023
1 parent 6e793b8 commit 9deac1b
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 51 deletions.
94 changes: 89 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,40 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo clippy -- -D warnings

release:
test-for-release:
needs: [check, fmt, clippy]
name: Semantic Release
name: Test for Release
runs-on: ubuntu-latest
if: github.actor != 'sbosnick-bot'

outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: semantic
with:
dry_run: true

- name: Update version
if: steps.semantic.outputs.new_release_published == 'true'
run: |
sed -i '/\[package\]/,/^version = "[^"]*"$/ s/^version = "[^"]*"$/version = "'"${{ steps.semantic.outputs.new_release_version }}"'"/' Cargo.toml
build-armhf:
needs: [test-for-release]
if: needs.test-for-release.outputs.new_release_published == 'true'

steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -59,14 +87,70 @@ jobs:
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable

- name: Build
run: |
./build-deb.sh ${{ needs.test-for-release.outputs.new_release_version }} arm-unknown-linux-gnueabihf
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: deb-armhf
path: target/arm-unknown-linux-gnueabihf/debian/bloop-box_3.2.0_armhf.deb

build-arm64:
needs: [test-for-release]
if: needs.test-for-release.outputs.new_release_published == 'true'

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable

- name: Build
run: |
./build-deb.sh ${{ needs.test-for-release.outputs.new_release_version }} aarch64-unknown-linux-gnu
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: deb-arm64
path: target/aarch64-unknown-linux-gnu/debian/bloop-box_3.2.0_arm64.deb

release:
needs: [build-armhf, build-arm64]
name: Semantic Release
runs-on: ubuntu-latest
if: needs.test-for-release.outputs.new_release_published == 'true'

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Download Build Artifacts
uses: actions/download-artifact@v3

- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable

- name: Update version
run: |
sed -i '/\[package\]/,/^version = "[^"]*"$/ s/^version = "[^"]*"$/version = "'"${{ steps.semantic.outputs.new_release_version }}"'"/' Cargo.toml
cargo update --package bloop-box --offline
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: semantic
with:
semantic_version: 19.0.5
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
5 changes: 1 addition & 4 deletions .releaserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ plugins:
- '@semantic-release/commit-analyzer'
- '@semantic-release/release-notes-generator'
- '@semantic-release/changelog'
- - '@semantic-release/exec'
- prepareCmd: "./semantic-release-build.sh ${nextRelease.version}"
- - '@semantic-release/github'
- assets:
- target/arm-unknown-linux-gnueabihf/debian/*.deb
- target/aarch64-unknown-linux-gnu/debian/*.deb
- deb-*/*.deb
- - '@semantic-release/git'
- assets:
- CHANGELOG.md
Expand Down
37 changes: 37 additions & 0 deletions build-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

VERSION="$1"
TARGET="$2"

cargo install cross --git https://github.com/cross-rs/cross
cargo install cargo-deb

sed -i '/\[package\]/,/^version = "[^"]*"$/ s/^version = "[^"]*"$/version = "'"$VERSION"'"/' Cargo.toml

cross build --target "$TARGET" --release || exit 1
cp -a "target/$TARGET/release/bloop-box" target/bloop-box || exit 1
cargo-deb -v --no-build --target "$TARGET" --no-strip || exit 1

# This is workaround for https://github.com/kornelski/cargo-deb/issues/47
# Patch the generated DEB to have ./ paths compatible with `unattended-upgrade`:
pushd "target/$TARGET/debian" || exit 1
DEB_FILE_NAME=$(ls -1 *.deb | head -n 1)
DATA_ARCHIVE=$(ar t "${DEB_FILE_NAME}"| grep -E '^data\.tar')
ar x "${DEB_FILE_NAME}" "${DATA_ARCHIVE}"
tar tf "${DATA_ARCHIVE}"

if [[ "${DATA_ARCHIVE}" == *.xz ]]; then
# Install XZ support that will be needed by TAR
apt-get -y install -y xz-utils
EXTRA_TAR_ARGS=J
fi

rm -rf tar-hack
mkdir tar-hack
tar -C tar-hack -xf "${DATA_ARCHIVE}"
pushd tar-hack || exit 1
tar c${EXTRA_TAR_ARGS}f "../${DATA_ARCHIVE}" --owner=0 --group=0 ./*
popd || exit 1
tar tf "${DATA_ARCHIVE}"
ar r "${DEB_FILE_NAME}" "${DATA_ARCHIVE}"
popd || exit 1
42 changes: 0 additions & 42 deletions semantic-release-build.sh

This file was deleted.

0 comments on commit 9deac1b

Please sign in to comment.