Skip to content

Release CD

Release CD #13

Workflow file for this run

name: Release CD
env:
DOCKERREPO: seblum/octivbooker
on:
workflow_dispatch:
push:
branches: master
paths:
- src/**
- poetry.Dockerfile
- pyproject.toml
- CHANGELOG.md
jobs:
release:
name: 🚀 Release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
steps:
-
uses: googleapis/release-please-action@v4
name: Release
id: release
with:
release-type: "python"
-
uses: actions/checkout@v4
-
name: 🏷️ Tag Major and Minor Versions
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
git tag -d v${{ steps.release.outputs.major }} || true
git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git push origin :v${{ steps.release.outputs.major }} || true
git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}"
git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}"
git push origin v${{ steps.release.outputs.major }}
git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}
poetry-version-tag:
runs-on: ubuntu-latest
needs: release
steps:
-
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
-
name: Extract tag version
id: extract_version
run: |
TAG_VERSION=$(git describe --match "v*.*.*" --tags --abbrev=0)
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
echo $TAG_VERSION
-
name: Update Version in pyproject.toml
run: |
sed -i "s/^version = \".*\"/version = \"$TAG_VERSION\"/" ./pyproject.toml
-
name: Verify Update
run: cat ./pyproject.toml
-
name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b update-version-$TAG_VERSION
git add pyproject.toml
git commit -m "Update version to $TAG_VERSION"
git push origin update-version-$TAG_VERSION
-
name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: bump-version-$TAG_VERSION
title: "Bump version to $TAG_VERSION"
body: "This PR updates the version in pyproject.toml to $TAG_VERSION."
base: main