Merge pull request #15 from REMLA24-Team-5/try-to-fix-version #36
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
# Only trigger on pr merges | |
name: Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
tag-and-release: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout repository | |
with: | |
fetch-depth: 0 | |
persist-credentials: true | |
- name: Configure Git Credentials | |
run: | | |
git config user.name "GitHub Actions [bot]" | |
git config user.email "[email protected]" | |
- name: Parse version info from tag | |
run: | | |
#get highest tag number | |
git status # This is just to check if the git checkout worked | |
echo "git status" | |
git pull # In case any changes were made since checkout | |
VERSION=`git describe --abbrev=0 --tags` | |
#replace . with space so can split into an array | |
VERSION_BITS=(${VERSION//./ }) | |
#get number parts and increase last one by 1 | |
VNUM1=${VERSION_BITS[0]} | |
VNUM2=${VERSION_BITS[1]} | |
VNUM3=${VERSION_BITS[2]} | |
VNUM3=$((VNUM3+1)) | |
#create new tag | |
NEW_TAG="$VNUM1.$VNUM2.$VNUM3" | |
echo "new_tag=$NEW_TAG" >> $GITHUB_ENV | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install & configure Poetry | |
uses: snok/[email protected] | |
with: | |
version: 1.5.1 | |
- name: Update poetry package version | |
run: poetry version ${{ env.new_tag }} | |
- name: Commit and push new version | |
run: | | |
git add pyproject.toml # Add dependency version changes | |
git commit -m "Update library version to ${{ env.new_tag }} [skip ci]" | |
git tag ${{ env.new_tag }} -m "Release ${{ env.new_tag }}" | |
git push --set-upstream origin $(git branch --show-current) --follow-tags | |
# Create a GitHub release from latest tag | |
gh release create ${{ env.new_tag }} \ | |
--title "${{ env.new_tag }}" \ | |
--generate-notes | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |