[PATCH] Correctly handle URLs for self-managed gitlab (#25) #39
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
# taken and adapted from: | |
# https://github.com/joaomcteixeira/python-project-skeleton/blob/master/.github/workflows/version-bump-and-package.yml | |
name: Version bump | |
on: | |
push: | |
branches: | |
- main | |
tags-ignore: | |
- '*' | |
jobs: | |
version_bump: | |
runs-on: ubuntu-latest | |
if: | | |
startsWith(github.event.head_commit.message, '[MAJOR]') || | |
startsWith(github.event.head_commit.message, '[MINOR]') || | |
startsWith(github.event.head_commit.message, '[PATCH]') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Setup Git | |
run: | | |
git config user.name github-actions[bot] | |
git config user.email github-actions[bot]@users.noreply.github.com | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
git checkout "${GITHUB_REF:11}" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install --upgrade -r requirements_release.txt | |
- name: Bump Major Version | |
env: | |
COMMIT_MSG: ${{ github.event.head_commit.message }} | |
run: bump2version major | |
if: startsWith(github.event.head_commit.message, '[MAJOR]') | |
- name: Bump Minor Version | |
env: | |
COMMIT_MSG: ${{ github.event.head_commit.message }} | |
run: bump2version minor | |
if: startsWith(github.event.head_commit.message, '[MINOR]') | |
- name: Bump Patch Version | |
env: | |
COMMIT_MSG: ${{ github.event.head_commit.message }} | |
run: bump2version patch | |
if: startsWith(github.event.head_commit.message, '[PATCH]') | |
- name: Commit version change to main | |
run: git push --follow-tags | |
code_checks: | |
needs: version_bump | |
uses: ./.github/workflows/_code_checks.yml | |
with: | |
ref: main | |
release: | |
needs: code_checks | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
fetch-depth: 0 # fetches entire history for all branches and tags | |
- name: Changelog | |
uses: Bullrich/generate-release-changelog@master | |
id: changelog | |
- name: Get latest tag | |
id: get_latest_tag | |
uses: WyriHaximus/github-action-get-previous-tag@v1 | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ steps.get_latest_tag.outputs.tag }} | |
release_name: ${{ steps.get_latest_tag.outputs.tag }} | |
body: ${{ steps.changelog.outputs.changelog }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish_package: | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Build pypi package | |
run: | | |
python -m pip install --upgrade pip | |
pip install --upgrade -r requirements_release.txt | |
make build_package | |
- name: Publish pypi package | |
run: | | |
make publish_package TWINE_USERNAME=__token__ TWINE_PASSWORD=${{ secrets.PYPI_API_TOKEN }} |