Skip to content

ci: use the MSRV to build releases #30

ci: use the MSRV to build releases

ci: use the MSRV to build releases #30

Workflow file for this run

name: bugbite-cli
on:
push:
tags: [bugbite-cli-*]
branches: ['**']
paths:
- ".github/workflows/bugbite-cli.yml"
workflow_dispatch:
jobs:
man:
runs-on: ubuntu-latest
container:
image: asciidoctor/docker-asciidoctor
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build docs
run: make -C doc man
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: man
path: target/doc/cli/man
if-no-files-found: error
retention-days: 3
msrv:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.msrv.outputs.version }}
steps:
- name: Checkout code to determine the minimum supported rust version
uses: actions/checkout@v4
- name: Get the minimum supported rust version (MSRV)
id: msrv
run: |
min_ver=$(sed -rn '/^rust-version\s*=/ s/^.*=\s*"([0-9](\.[0-9]+)+)(.*)/\1/p' Cargo.toml)
if [[ -n ${min_ver} ]]; then
echo "version=${min_ver}" >> $GITHUB_OUTPUT
else
exit 1
fi
shellcomp:
needs: msrv
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.msrv.outputs.version }}
- name: Generate files
run: cargo run --features shell --bin bite-shell-comp -p bugbite-cli
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: shellcomp
path: shell
if-no-files-found: error
retention-days: 3
source:
if: startsWith(github.ref, 'refs/tags/')
needs: [man, shellcomp, msrv]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.msrv.outputs.version }}
- name: Create vendored release
run: .ci/vendor-release bugbite-cli
- name: Download generated man pages
uses: actions/download-artifact@v4
with:
name: man
path: man
- name: Download generated shell completion
uses: actions/download-artifact@v4
with:
name: shellcomp
path: shell
- name: Create archive
run: |
# move shell completion files into the release
mv man shell ${{ github.ref_name }}
# create the release tarball
tar -cv -I "xz -9 -T0" -f ${{ github.ref_name }}.tar.xz ${{ github.ref_name }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: source
path: ${{ github.ref_name }}.tar.xz
if-no-files-found: error
retention-days: 3
linux:
needs: msrv
runs-on: ubuntu-22.04
strategy:
matrix:
target:
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- powerpc64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.msrv.outputs.version }}
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build binary
run: cross build --target ${{ matrix.target }} --profile release-strip -p bugbite-cli
- name: Create archive
run: |
tar -C target/${{ matrix.target }}/release-strip \
-cv -I "xz -9 -T0" -f ${{ github.ref_name }}-${{ matrix.target }}.tar.xz \
bite
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.ref_name }}-${{ matrix.target }}
path: ${{ github.ref_name }}-${{ matrix.target }}.tar.xz
if-no-files-found: error
retention-days: 3
macos:
needs: msrv
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.msrv.outputs.version }}
- name: Build binary
run: cargo build --profile release-strip -p bugbite-cli
- name: Create archive
run: |
cd target/release-strip
zip $GITHUB_WORKSPACE/${{ github.ref_name }}-macos.zip bite
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.ref_name }}-macos
path: ${{ github.ref_name }}-macos.zip
if-no-files-found: error
retention-days: 3
publish:
if: startsWith(github.ref, 'refs/tags/')
needs: ["source", "linux", "macos"]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/*.tar.xz
artifacts/${{ github.ref_name }}-macos.zip
fail_on_unmatched_files: true