Skip to content

Commit

Permalink
chore(ci): align ci and release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyscot committed Oct 31, 2024
1 parent 4fbf8f8 commit 9258314
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 28 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,50 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- name: Install tools
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
if: matrix.host != matrix.target
- name: Install cargo-deb
uses: taiki-e/install-action@v2
with:
tool: cross,cargo-deb
tool: cargo-deb
#- name: Set minimal profile (Windows only)
# if: matrix.host == 'windows-latest'
# run: rustup set profile minimal
- uses: Swatinem/rust-cache@v2
with:
key: "${{ matrix.build }}"
cache-on-failure: true
- name: install packages (ubuntu hosts only)
- name: install packages (ubuntu builds only)
if: startsWith(matrix.host, 'ubuntu')
run: scripts/install-ubuntu-packages
# native builds need all of these; cross builds only need binutils-multiarch

- uses: taiki-e/upload-rust-binary-action@v1
id: build
with:
bin: qcp
token: ${{ secrets.GITHUB_TOKEN }}
target: ${{ matrix.target }}
include: README.md,LICENSE,CHANGELOG.md
leading-dir: true
build-tool: cross
tar: unix
zip: windows
dry_run: true
# TODO: add --locked when supported
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: qcp-tarball-${{ matrix.target }}
path: ${{ steps.build.outputs.archive }}.tar.gz

- name: Build
run: cross build --release --locked --target ${{ matrix.target }}
- name: Make debian package
if: ${{ matrix.build_deb }}
run: scripts/make-debian-package ${{ matrix.target }}

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: qcp-bin-${{ matrix.target }}
path: target/${{ matrix.target }}/release/qcp
- name: Upload deb
- name: Upload deb artifact
if: ${{ matrix.build_deb }}
uses: actions/upload-artifact@v4
with:
Expand Down
53 changes: 40 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ name: release
on:
release:
types: [published]
# running on push is sometimes useful for testing; also enable WORKFLOW_TEST
#push:
# branches:
# - misc/build-aarch64
workflow_dispatch: # for testing

env:
WORKFLOW_TEST: false
CARGO_TERM_COLOR: always
WORKFLOW_TEST: GITHUB_EVENT_NAME == 'workflow_dispatch'

permissions:
contents: write
Expand All @@ -23,10 +21,12 @@ jobs:
host: ubuntu-latest
target: x86_64-unknown-linux-musl
rust: stable
build_deb: true
- build: aarch64-musl
host: ubuntu-latest
target: aarch64-unknown-linux-musl
rust: stable
build_deb: true
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v4
Expand All @@ -35,15 +35,23 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@v2
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
tool: cross
target: ${{ matrix.target }}
if: matrix.host != matrix.target
- name: Install cargo-deb
uses: taiki-e/install-action@v2
with:
tool: cargo-deb
- uses: Swatinem/rust-cache@v2
with:
key: "${{matrix.build}}"
#- name: install packages (ubuntu)
# if: startsWith(matrix.host, 'ubuntu')
# run: scripts/install-ubuntu-packages
key: "${{ matrix.build }}"
- name: install packages (ubuntu hosts only)
if: startsWith(matrix.host, 'ubuntu')
run: scripts/install-ubuntu-packages
# native builds need all of these; cross builds only need binutils-multiarch

- uses: taiki-e/upload-rust-binary-action@v1
id: build
with:
Expand All @@ -52,11 +60,30 @@ jobs:
target: ${{ matrix.target }}
include: README.md,LICENSE,CHANGELOG.md
leading-dir: true
build-tool: cross
tar: unix
zip: windows
dry_run: ${{ env.WORKFLOW_TEST }}
# Uploading the artifact is useful when testing the workflow in dry-run mode
- uses: actions/upload-artifact@v4
# TODO: add --locked when supported

- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: qcp-tarball-${{ matrix.target }}
path: ${{ steps.build.outputs.archive }}.tar.gz

- name: Make debian package
if: ${{ matrix.build_deb }}
run: scripts/make-debian-package ${{ matrix.target }}
- name: Upload deb artifact
if: ${{ matrix.build_deb }}
uses: actions/upload-artifact@v4
with:
name: qcp-deb-${{ matrix.target }}
path: target/**/debian/qcp*.deb
- name: Publish artifact to release
if: ! ${{ env.WORKFLOW_TEST }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.ref }} ${{ env.BUILT_DEB_FILE }}

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ private_intra_doc_links = "deny"
unescaped_backticks = "deny"

[package.metadata.cross.target.x86_64-unknown-linux-musl]
pre-build = [ "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install capnproto" ]
pre-build = [ "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends -o Dpkg::Options::=--force-confnew install capnproto musl-tools" ]
linker = "x86_64-linux-musl-gcc"

[package.metadata.cross.target.aarch64-unknown-linux-musl]
pre-build = [ "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install capnproto" ]
pre-build = [ "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends -o Dpkg::Options::=--force-confnew install capnproto musl-tools" ]
#linker = "aarch64-linux-musl-gcc"

[package.metadata.deb]
extended-description = """\
Expand Down
3 changes: 2 additions & 1 deletion scripts/make-debian-package
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ fi
set -x

gzip -9n < CHANGELOG.md > misc/changelog.gz
cargo deb --no-build --locked ${TARGETOPT} --deb-revision ""
deb=$(cargo deb --no-build --locked ${TARGETOPT} --deb-revision "")
echo "BUILT_DEB_FILE=${deb}" >> "$GITHUB_ENV"

0 comments on commit 9258314

Please sign in to comment.