Skip to content

Semantic Release

Semantic Release #47

name: Semantic Release
on:
workflow_dispatch:
inputs:
is_prerelease:
description: 'Is this a prerelease?'
required: false
default: true
type: boolean
permissions:
contents: read
jobs:
semantic-release:
name: Check if new release 🔖 needed ❔
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
environment:
name: sem-ver
concurrency: release
outputs:
is_prerelease: ${{ steps.semantic_release.outputs.is_prerelease }}
released: ${{ steps.semantic_release.outputs.released }}
version: ${{ steps.semantic_release.outputs.version }}
tag: ${{ steps.semantic_release.outputs.tag }}
permissions:
id-token: write
contents: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Debug | Input variables
run: |
echo "## Inputs" >> $GITHUB_STEP_SUMMARY
echo "Is prerelease - " ${{ inputs.is_prerelease }} | tee $GITHUB_STEP_SUMMARY
- name: Setup | Checkout Repository at workflow sha
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
fetch-depth: 0
ref: ${{ github.sha }}
- name: Setup | Force correct release branch on workflow sha
run: git checkout -B ${{ github.ref_name }} ${{ github.sha }}
- name: Setup | Get short commit SHA
id: vars
run: echo "short_sha=$(git rev-parse --short HEAD)\n" >> $GITHUB_OUTPUT
- name: Action | Semantic Release - Update version
id: semantic_release
# Adjust tag with desired version if applicable.
uses: python-semantic-release/python-semantic-release@c1bcfdbb994243ac7cf419365d5894d6bfb2950e # v9.12.0
with:
github_token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "[email protected]"
build: false
changelog: true
commit: true
push: true
tag: true
prerelease: ${{ inputs.is_prerelease }}
vcs_release: true
- name: Action | Output version info
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Results of python-semantic-version" >> $GITHUB_STEP_SUMMARY
echo "Released " ${{ steps.semantic_release.outputs.released }} >> $GITHUB_STEP_SUMMARY
echo "Prerelease " ${{ steps.semantic_release.outputs.is_prerelease }} >> $GITHUB_STEP_SUMMARY
echo "Version " ${{ steps.semantic_release.outputs.version }} >> $GITHUB_STEP_SUMMARY
echo "Tag " ${{ steps.semantic_release.outputs.tag }} >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY