-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add get version endpoint * remove auto-bump * add release mechanism
- Loading branch information
Showing
2 changed files
with
74 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,26 +65,4 @@ jobs: | |
shell: bash -l {0} | ||
run: | | ||
pytest | ||
deploy: | ||
name: Tag a new version and push tag | ||
runs-on: ubuntu-latest | ||
needs: test | ||
if: github.ref == 'refs/heads/master' | ||
steps: | ||
- name: git checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
fetch-depth: 0 | ||
- name: bumpversion | ||
shell: bash -l {0} | ||
run: | | ||
git config --global user.name "github-actions" | ||
git config --global user.email "[email protected]" | ||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | ||
pip install bumpversion | ||
bumpversion patch | ||
git push | ||
git push --tags | ||
TAG=$(git describe --tags) | ||
echo "tag=$TAG" >> $GITHUB_ENV | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# REF: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#the-whole-ci-cd-workflow | ||
name: publish release | ||
|
||
on: | ||
# run this workflow when manually triggered | ||
workflow_dispatch: | ||
inputs: | ||
part: | ||
description: "Semver part to bump (major, minor, patch)" | ||
type: choice | ||
required: true | ||
default: "patch" | ||
options: ["major", "minor", "patch"] | ||
dry-run: | ||
description: "Dry run" | ||
type: boolean | ||
required: true | ||
default: false | ||
skip-tests: | ||
description: "Skip tests" | ||
type: boolean | ||
required: true | ||
default: false | ||
|
||
jobs: | ||
bump: | ||
name: Bump version | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
id-token: write | ||
outputs: | ||
VERSION: ${{ steps.get-version.outputs.VERSION }} | ||
SHORT_VERSION: ${{ steps.get-version.outputs.SHORT_VERSION }} | ||
MAJOR_VERSION: ${{ steps.get-version.outputs.MAJOR_VERSION }} | ||
MINOR_VERSION: ${{ steps.get-version.outputs.MINOR_VERSION }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Get tags | ||
run: git fetch --tags origin | ||
- name: Configure git for github-actions[bot] | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
- name: Install Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
- name: Install bumpversion | ||
run: pip install bumpversion | ||
- name: Bump version with bumpversion | ||
run: | | ||
bumpversion ${{ github.event.inputs.part }} | ||
- name: Commit and push with tags | ||
if: ${{ github.event.inputs.dry-run == 'false' }} | ||
run: git push --follow-tags | ||
- name: Get version | ||
id: get-version | ||
run: | | ||
version="$(git describe --tags)" | ||
# remove the leading v from version | ||
version="${version:1}" | ||
echo "VERSION=$version" >> $GITHUB_OUTPUT | ||
major_version="$(cut -d '.' -f 1 <<< $version)" | ||
echo "MAJOR_VERSION=$major_version" >> $GITHUB_OUTPUT | ||
minor_version="$(cut -d '.' -f 2 <<< $version)" | ||
echo "MINOR_VERSION=$minor_version" >> $GITHUB_OUTPUT | ||
short_version="$major_version.$minor_version" | ||
echo "SHORT_VERSION=$short_version" >> $GITHUB_OUTPUT | ||
- name: Show short version | ||
run: echo ${{ steps.get-version.outputs.SHORT_VERSION }} |