Skip to content

Update Specmatic Version and Publish #27

Update Specmatic Version and Publish

Update Specmatic Version and Publish #27

name: Update Specmatic Version and Publish
on:
workflow_dispatch:
inputs:
specmatic-core-version:
description: Specmatic Core Version
required: false
type: string
default: ''
permissions:
contents: write
concurrency:
group: release-${{ github.event.inputs.specmatic-core-version }}
cancel-in-progress: false
jobs:
update-specmatic-version-and-publish:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.specmatic-core-version != '' }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
- name: Configure git cli
run: |
git config --global user.email "github-service-account@specmatic.io"
git config --global user.name "Specmatic GitHub Service Account"
- name: Update version in version.py
run: |
SPEC_VERSION="${{ github.event.inputs.specmatic-core-version }}"
sed -i "s/__version__ = '[^']*'/__version__ = '$SPEC_VERSION'/" specmatic/version.py
sed -i "s/__specmatic_version__ = '[^']*'/__specmatic_version__ = '$SPEC_VERSION'/" specmatic/version.py
if git diff --exit-code specmatic/version.py; then
echo "::error::No changes made to version.py - version may already be set to $SPEC_VERSION"
exit 1
else
echo "Version updated successfully to $SPEC_VERSION"
fi
- name: Commit and push changes
run: |
git add specmatic/version.py
git commit -m "chore: bump version and specmatic_version to ${{ github.event.inputs.specmatic-core-version }}"
git push
- name: Check if tag exists and create
run: |
TAG="${{ github.event.inputs.specmatic-core-version }}"
if git show-ref --tags --verify --quiet "refs/tags/${TAG}"; then
echo "::error::Tag ${TAG} already exists"
exit 1
fi
git tag "${TAG}"
git push origin "${TAG}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: "${{ github.event.inputs.specmatic-core-version }}"
name: "v${{ github.event.inputs.specmatic-core-version }}"
token: ${{ secrets.SPECMATIC_GITHUB_TOKEN }}
generate_release_notes: true