Skip to content

Commit

Permalink
get version
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Nov 26, 2024
1 parent 43b1672 commit 0c26570
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ on:
workflow_dispatch:

jobs:
test:
uses: ocadotechnology/codeforlife-workspace/.github/workflows/test-python-code.yaml@main
secrets: inherit
with:
python-version: 3.12
# test:
# uses: ocadotechnology/codeforlife-workspace/.github/workflows/test-python-code.yaml@main
# secrets: inherit
# with:
# python-version: 3.12

# TODO: https://python-semantic-release.readthedocs.io/en/latest/automatic-releases/github-actions.html#common-workflow-example
release:
concurrency: release
runs-on: ubuntu-latest
needs: [test]
# needs: [test]
permissions:
id-token: write
# Release if:
Expand All @@ -30,6 +30,8 @@ jobs:
if: |
github.repository_owner_id == 2088731 &&
github.ref_name == github.event.repository.default_branch
env:
PYTHON_SCRIPT: "from codeforlife.version import __version__; print(__version__)"
steps:
- name: 🛫 Checkout
uses: actions/checkout@v4
Expand All @@ -46,6 +48,12 @@ jobs:
with:
python-version: 3.12

- name: 🔍 Get Old Version
run: |
OLD_VERSION=$(python -c "$PYTHON_SCRIPT")
echo $OLD_VERSION
echo OLD_VERSION=$OLD_VERSION >> $GITHUB_ENV
- name: 🛠 Install Dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -59,5 +67,12 @@ jobs:
GH_TOKEN: ${{ secrets.CFL_BOT_GITHUB_TOKEN }}
run: semantic-release publish --verbosity=INFO

- name: 🔍 Get New Version
run: |
NEW_VERSION=$(python -c "$PYTHON_SCRIPT")
echo $NEW_VERSION
echo NEW_VERSION=$NEW_VERSION >> $GITHUB_ENV
- name: 🚀 Publish to PyPI
if: env.OLD_VERSION != env.NEW_VERSION
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit 0c26570

Please sign in to comment.