📦 Release minor/ by @wayjam #14
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: 0x📦 Release New Version | |
run-name: 📦 Release ${{ inputs.semver }}/${{ inputs.custom_version }} by @${{ github.actor }} ${{ inputs.dry_run && '(🧪 Dry-Run)' || '' }} | |
on: | |
workflow_dispatch: | |
inputs: | |
semver: | |
type: choice | |
description: Which version you want to increment? | |
options: | |
- patch | |
- minor | |
- major | |
required: true | |
custom_version: | |
description: Manual Custom Version (Special Purpose, e.g. 1.0.0) | |
type: string | |
required: false | |
dry_run: | |
description: "Dry run?" | |
type: boolean | |
default: false | |
jobs: | |
check_tests: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
outputs: | |
should_test: ${{ steps.check.outputs.should_test }} | |
steps: | |
- name: Check if tests have already run | |
id: check | |
run: | | |
CHECK_RUNS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/check-runs") | |
ALL_PASSED=$(echo "$CHECK_RUNS" | jq -r '.check_runs | all(.conclusion == "success")') | |
echo "ALL_PASSED=$ALL_PASSED" | |
if [ "$ALL_PASSED" == "true" ]; then | |
echo "All tests have already passed for this commit. Skipping tests." | |
echo "should_test=false" >> $GITHUB_OUTPUT | |
else | |
echo "Some tests haven't run or passed for this commit. Running tests." | |
echo "should_test=true" >> $GITHUB_OUTPUT | |
fi | |
test: | |
needs: check_tests | |
if: needs.check_tests.outputs.should_test == 'true' | |
uses: ./.github/workflows/test.yml | |
release: | |
needs: [check_tests, test] | |
if: always() && (needs.check_tests.outputs.should_test == 'false' || needs.test.result == 'success') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
actions: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Bump version and push tag | |
id: tag_version | |
uses: mathieudutour/github-tag-action@v6.2 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
default_bump: ${{ inputs.semver }} | |
custom_tag: ${{ inputs.custom_version }} | |
- name: Create a GitHub release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.tag_version.outputs.new_tag }} | |
name: Release ${{ steps.tag_version.outputs.new_tag }} | |
body: ${{ steps.tag_version.outputs.changelog }} | |
draft: ${{ inputs.dry_run }} | |
- name: Dispatch Build | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
workflow: build.yml | |
inputs: '{ "dry_run": ${{ inputs.dry_run }} }' |