Skip to content

Commit

Permalink
DEV: Release using the REL commit instead of git tag (#2500)
Browse files Browse the repository at this point in the history
The git tag is automatically added

Co-authored-by: Stefan <[email protected]>
  • Loading branch information
MartinThoma and stefan6419846 authored Mar 29, 2024
1 parent 8dbfeba commit 12c3784
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,45 @@
name: Publish Python Package to PyPI
on:
push:
tags:
- '*.*.*'
branches:
- main
permissions:
contents: write

jobs:
build_and_publish:
name: Publish a new version of pypdf
runs-on: ubuntu-latest
if: "${{ startsWith(github.event.head_commit.message, 'REL: ') }}"

steps:
# Ensure it's on PyPI
- name: Checkout Repository
uses: actions/checkout@v4
- name: Extract version from commit message
id: extract_version
run: |
VERSION=$(echo "${{ github.event.head_commit.message }}" | grep -oP '(?<=REL: )\d+\.\d+\.\d+')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Extract tag message from commit message
id: extract_message
run: |
VERSION="${{ steps.extract_version.outputs.version }}"
delimiter="$(openssl rand -hex 8)"
MESSAGE=$(echo "${{ github.event.head_commit.message }}" | sed "0,/REL: $VERSION/s///" )
echo "message<<${delimiter}" >> $GITHUB_OUTPUT
echo "$MESSAGE" >> $GITHUB_OUTPUT
echo "${delimiter}" >> $GITHUB_OUTPUT
- name: Create Git Tag
run: |
VERSION="${{ steps.extract_version.outputs.version }}"
MESSAGE="${{ steps.extract_message.outputs.message }}"
git config user.name github-actions
git config user.email [email protected]
git tag "$VERSION" -m "$MESSAGE"
git push origin $VERSION
- name: Set up Python
uses: actions/setup-python@v5
Expand Down

0 comments on commit 12c3784

Please sign in to comment.