Skip to content

Add code coverage instrumentation to CI pipeline #91

Add code coverage instrumentation to CI pipeline

Add code coverage instrumentation to CI pipeline #91

Workflow file for this run

name: Release
# This workflow is not ordered after the 'Lint' workflow. And doing so is difficult, because
# workflow_run: only applies on the default branch, and I EXPRESSLY WANT this workflow to run in PRs
# too, because it validates some preconditions for making the release.
#
# So make the assumption that if the PR pipeline passed, and this workflow runs on the default
# branch, it's okay to make a release without waiting for the build and test
on: push
jobs:
trigger-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# https://github.com/Notgnoshi/herostratus/settings/secrets/actions
# https://github.com/settings/personal-access-tokens
token: ${{ secrets.HEROSTRATUS_RELEASE_TOKEN }}
- name: Validate SemVer Version
shell: bash # Explicitly setting the shell sets errexit and pipefail flags
run: |
VERSION="$(.github/parse-manifest-key.sh Cargo.toml version)"
echo "Validating SemVer version '$VERSION' ..."
.github/validate-version-is-semver-compliant.sh "$VERSION"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Check if current version has a Git tag
shell: bash
if: github.ref_name == github.event.repository.default_branch
run: |-
# Delete any local tags cached by the runner, and fetch remote tags to ensure we're
# up-to-date.
git tag --list | xargs git tag --delete
git fetch --force --tags
# Exits with success if tag does not exist, failure if tag _does_ exist.
if ! .github/check-if-tag-already-exists.sh \
--tag-prefix 'v' \
--target-branch 'main' \
"$VERSION" \
; then
echo "Found tag for current version '$VERSION'. Skipping release ..."
else
echo "Could not find tag for current version '$VERSION'. Making relese ..."
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
RELEASE_TAG="v$VERSION"
git tag --annotate --message "Auto-generated release tag $RELEASE_TAG generated by GitHub Action run by ${{ github.actor }}" "$RELEASE_TAG"
git push origin "refs/tags/$RELEASE_TAG"
fi
# Run all jobs except "Make The Release" on every push event
generate-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract Release Metadata
shell: bash
run: |
VERSION="$(.github/parse-manifest-key.sh Cargo.toml version)"
DESCRIPTION="$(.github/parse-manifest-key.sh Cargo.toml description)"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "DESCRIPTION=$DESCRIPTION" >> "$GITHUB_ENV"
# Always generate release notes for the current version. If the version from the Cargo
# manifest isn't found in the CHANGELOG.md, then fail the pipeline (even in PRs)
- name: Generate Release Notes
shell: bash
run: .github/get-release-notes.sh "$VERSION" "$DESCRIPTION" | tee release.md
- name: Make The Release
uses: softprops/action-gh-release@v2
# Only actually make the release on a tag
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: release.md
prerelease: ${{ contains(env.VERSION, '-rc') }}
token: ${{ secrets.HEROSTRATUS_RELEASE_TOKEN }}