From 82659244c4aea64426d059fae3a8e620d4481e07 Mon Sep 17 00:00:00 2001 From: Mark Beacom <7315957+mbeacom@users.noreply.github.com> Date: Tue, 14 Feb 2023 14:39:52 -0500 Subject: [PATCH] Add GitHub action to publish to PyPi and GH on tag --- .github/workflows/publish.yaml | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..d48e026 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,49 @@ +name: 'Publish Release' + +on: + push: + tags: + - '*' + +jobs: + publish: + name: Publish Release + runs-on: ubuntu-latest + steps: + - name: Checkout Source + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Dependencies + uses: './.github/actions/dep-setup' + with: + python-version: '3.10' + + - name: Run Safety Check + run: poetry poe safety + + - name: Get Python Module Version + run: | + MODULE_VERSION=$(poetry version --short) + echo "MODULE_VERSION=$MODULE_VERSION" >> $GITHUB_ENV + + - name: Verify Versions Match + run: | + TAG_VERSION=$(git describe HEAD --tags --abbrev=0) + echo "Git Tag Version: $TAG_VERSION" + echo "Python Module Version: $MODULE_VERSION" + if [[ "$TAG_VERSION" != "$MODULE_VERSION" ]]; then exit 1; fi + + - name: Publish to PyPi + run: poetry publish --build + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }} + + - name: Release + uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true + files: | + dist/eksupgrade-${{env.MODULE_VERSION}}-py3-none-any.whl + dist/eksupgrade-${{env.MODULE_VERSION}}.tar.gz