chore(main): release 0.5.0 #91
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: "Build & Test" | |
on: [push] | |
jobs: | |
set-vars: | |
name: "Set workflow variables" | |
runs-on: ubuntu-latest | |
outputs: | |
release_tag: ${{ steps.check_tag.outputs.match }} | |
steps: | |
- name: Determine release tag | |
id: check_tag | |
run: | | |
echo "event.ref: ${{ github.event.ref }}" | |
echo "ref_name: ${{ github.ref_name }}" | |
echo "ref: ${{ github.ref }}" | |
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "match=true" >> $GITHUB_OUTPUT | |
echo "Setting check_tag to true" | |
else | |
echo "match=false" >> $GITHUB_OUTPUT | |
echo "Setting check_tag to false" | |
fi | |
static-analysis: | |
needs: set-vars | |
name: Run static analysis | |
runs-on: ubuntu-latest | |
env: | |
BREADLOG_PKG_URL: "https://github.com/jamesmistry/breadlog/releases/download/v0.4.0/breadlog-package-linux_x86-64.tar.gz" | |
steps: | |
- name: Setup | Checkout | |
uses: actions/checkout@v3 | |
- name: Setup | Prerequisites | |
run: "sudo bash -c 'apt update && DEBIAN_FRONTEND=noninteractive apt install -y curl'" | |
- name: Setup | Breadlog | |
run: 'curl --proto "=https" -LsSf "${BREADLOG_PKG_URL}" | sudo tar -xz -C /' | |
- name: Breadlog Check | App | |
run: "breadlog -c ./Breadlog.yaml --check" | |
- name: Setup | Rust | |
run: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y" | |
- name: Setup | Rust Nightly | |
run: "rustup install nightly && rustup default nightly" | |
- name: Setup | Code Formatter | |
run: "rustup update && rustup component add rustfmt" | |
- name: Setup | Linter | |
run: "rustup update && rustup component add clippy" | |
- name: Code Format Check | App | |
run: "cargo +nightly fmt -- --check --config-path ./" | |
- name: Lint | App | |
run: "cargo clippy -- -A 'clippy::empty-docs' -D warnings" | |
build: | |
needs: [static-analysis, set-vars] | |
name: Build and run tests | |
# Provides glibc 2.31 | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Setup | Checkout | |
uses: actions/checkout@v3 | |
- name: Setup | Prerequisites | |
run: "sudo bash -c 'apt update && DEBIAN_FRONTEND=noninteractive apt install -y curl'" | |
- name: Setup | Rust | |
run: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y" | |
- name: Setup | Rust Nightly | |
run: "rustup install nightly && rustup default nightly" | |
- name: Setup | LLVM Tooling | |
run: "rustup component add llvm-tools-preview" | |
- name: Setup | LLVM helper | |
run: "cargo install cargo-binutils && rustup component add llvm-tools-preview" | |
- name: Tests | App | |
run: './.github/workflows/test_with_coverage.bash "$(pwd)" &> ./small_test_coverage_report.txt && cat ./small_test_coverage_report.txt' | |
- name: Clean artifacts from test | App | |
run: 'rm -rf ./target/*' | |
- name: Create build environment | App | |
run: "docker build --file build.Dockerfile -t breadlog:build ./" | |
- name: Build | App | |
run: "docker run -e 'REPO_DIR=/var/repo' --mount type=bind,source='./',target='/repo' breadlog:build" | |
- name: Store code coverage report | App | |
uses: actions/upload-artifact@v3 | |
with: | |
name: small_test_coverage_report | |
path: small_test_coverage_report.txt | |
retention-days: 7 | |
- name: Store debug output | App | |
uses: actions/upload-artifact@v3 | |
with: | |
name: breadlog-debug | |
path: target/debug/breadlog | |
retention-days: 7 | |
- name: Store release output | App | |
uses: actions/upload-artifact@v3 | |
with: | |
name: breadlog-release | |
path: target/release/breadlog | |
retention-days: 7 | |
- name: Build package | App | |
run: 'BREADLOG_TMP="$(mktemp -d)"; mkdir -p "${BREADLOG_TMP}/usr/bin" && cp target/release/breadlog "${BREADLOG_TMP}/usr/bin/breadlog" && tar -C "${BREADLOG_TMP}" -czf /tmp/breadlog_package.tar.gz usr' | |
- name: Upload package artifact | App | |
uses: actions/upload-artifact@v3 | |
with: | |
name: breadlog-package | |
path: /tmp/breadlog_package.tar.gz | |
upload-assets: | |
# This job will only run on a release tag, which will have been created by | |
# release-please along with a GitHub release. A GitHub release associated | |
# with the tag is therefore guaranteed to exist before this job runs, | |
# providing a location to upload the release artifacts. | |
# | |
# Note that there is a race condition between this workflow being triggered | |
# by release-please pushing a tag and creating the GH release, but given the | |
# other jobs in the workflow it is safe to assume a GH release will have | |
# been created in time. | |
# | |
# 2 packages with identical content but different names are uploaded: one | |
# is for manual download and contains the release version in the name | |
# while the other is for downloading from within user CI pipelines and | |
# doesn't contain the release version in the name. This allows CI pipelines | |
# to easily download the latest package from a single, consistent URL. | |
needs: [set-vars, build] | |
env: | |
USER_PACKAGE_NAME: "/tmp/breadlog-package-${{ github.ref_name }}-linux_x86-64.tar.gz" | |
CI_PACKAGE_NAME: "/tmp/breadlog-package-linux_x86-64.tar.gz" | |
PACKAGE_HASH_NAME: "/tmp/breadlog-package-linux_x86-64.sha256" | |
name: Upload release assets | |
if: needs.set-vars.outputs.release_tag == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: breadlog-package | |
- name: Store package hash | Release | |
run: 'sha256sum ./breadlog_package.tar.gz | cut -d " " -f 1 > "${PACKAGE_HASH_NAME}"' | |
- name: Create user package | Release | |
run: 'cp "./breadlog_package.tar.gz" "${USER_PACKAGE_NAME}"' | |
- name: Create CI package | Release | |
run: 'cp "./breadlog_package.tar.gz" "${CI_PACKAGE_NAME}"' | |
- name: Auth GH CLI | Release | |
run: 'echo "${{ secrets.BREADLOG_RELEASE_PAT }}" | gh auth login --with-token' | |
- name: Upload user release artifact | Release | |
run: 'gh release upload "${{github.ref_name}}" "${USER_PACKAGE_NAME}#Installer archive (Linux x86-64)"' | |
- name: Upload CI release artifact | Release | |
run: 'gh release upload "${{github.ref_name}}" "${CI_PACKAGE_NAME}"' | |
- name: Upload package hash | Release | |
run: 'gh release upload "${{github.ref_name}}" "${PACKAGE_HASH_NAME}#Installer hash (Linux x86-64)"' | |