update unit tests workflow to also publish artifacts on workflow disp… #6
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: "Bump version" | ||
run-name: "Bump branch `${{ inputs.branch }}` to `${{ inputs.version }}`" | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: "The branch to bump" | ||
type: string | ||
default: "main" | ||
version: | ||
description: "The version to bump to" | ||
required: true | ||
working-dir: | ||
description: "The working directory, useful for mono-repos" | ||
default: "./" | ||
workflow_call: | ||
inputs: | ||
branch: | ||
description: "The branch to bump" | ||
type: string | ||
default: "main" | ||
version: | ||
description: "The version to bump to" | ||
type: string | ||
required: true | ||
working-dir: | ||
description: "The working directory, useful for mono-repos" | ||
type: string | ||
default: "./" | ||
outputs: | ||
current-version: ${{ jobs.bump-version.outputs.version }} | ||
bumped: ${{ jobs.bump-version.outputs.bumped }} | ||
permissions: write-all | ||
# only bump a branch/working-dir (package) to one version at a time | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ inputs.branch }}-${{ inputs.working-dir }} | ||
cancel-in-progress: true | ||
env: | ||
NOTIFICATION_PREFIX: "[Bump version]" | ||
jobs: | ||
debug-inputs: | ||
name: "[DEBUG] Inputs" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "[DEBUG] Inputs" | ||
run: | | ||
echo branch : ${{ inputs.branch }} | ||
echo version : ${{ inputs.version }} | ||
echo working-dir : ${{ inputs.working-dir }} | ||
echo NOTIFICATION_PREFIX : ${{ env.NOTIFICATION_PREFIX }} | ||
bump-version: | ||
name: "Bump `${{ inputs.branch}}` to `${{ inputs.version }}`" | ||
runs-on: ubuntu-latest | ||
outputs: | ||
current-version: ${{ steps.current-version.outputs.version }} | ||
bumped: ${{ steps.current-version.outputs.bumped }} | ||
steps: | ||
- name: "Check out `${{ inputs.branch }}`" | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.branch }} | ||
- name: "Setup `hatch`" | ||
uses: ./.github/actions/setup-hatch | ||
- name: "Current version" | ||
id: current-version | ||
shell: bash | ||
run: | | ||
echo "version=$(hatch version)" >> $GITHUB_OUTPUT | ||
if [[ $(hatch version) == "${{ inputs.version }} ]] | ||
then | ||
echo "bumped=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "bumped=true" >> $GITHUB_OUTPUT | ||
fi | ||
- name: "Bump version" | ||
if: ${{ steps.current-version.outputs.version != inputs.version }} | ||
shell: bash | ||
run: hatch version ${{ inputs.version }} | ||
working-directory: ${{ inputs.working-dir }} | ||
- name: "Commit and push changes" | ||
if: ${{ steps.current-version.outputs.version != inputs.version }} | ||
uses: ./.github/actions/commit | ||
with: | ||
message: "[automated] bump version to ${{ inputs.version }}" | ||
- name: "[INFO] Bumped version" | ||
if: ${{ steps.current-version.outputs.version != inputs.version }} | ||
run: | | ||
title="Bumped version" | ||
message="Bumped from ${{ steps.current-version.outputs.version }} to ${{ inputs.version }}" | ||
echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" | ||
- name: "[INFO] Skipped version bump" | ||
if: ${{ steps.current-version.outputs.version == inputs.version }} | ||
run: | | ||
title="Skipped version bump" | ||
message="${{ inputs.branch }} is already at version ${{ inputs.version }}" | ||
echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" |