-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip ci] revamp github actions release and lint workflow
- use hatch build system - use pypi trusted publisher upload method - update checkout action version - use artifacts on each run
- Loading branch information
Showing
4 changed files
with
83 additions
and
82 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
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 |
---|---|---|
@@ -1,79 +1,81 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
testing: | ||
description: 'Publish to PyPI testing' | ||
required: true | ||
type: boolean | ||
push: | ||
branches: [master, develop] | ||
tags: | ||
- "v*.*.*" | ||
|
||
jobs: | ||
release: | ||
name: Publish Release | ||
build: | ||
name: Build Distribution | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install poetry | ||
run: pipx install poetry | ||
- name: Set up Python >= 3.10 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '>=3.10' | ||
cache: pip | ||
|
||
- name: Set up Python 3.x | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
cache: 'poetry' | ||
- name: Install hatch | ||
run: pip install -U hatch hatch-vcs | ||
|
||
- name: Build project for distribution | ||
run: poetry build | ||
- name: Build Project | ||
run: hatch build | ||
|
||
- name: Get Package Version | ||
id: check-version | ||
run: | | ||
VERSION=$(poetry version --short) | ||
echo "version=v$VERSION" >> $GITHUB_ENV | ||
[[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: bing-rewards | ||
path: dist/ | ||
|
||
- name: Setup Git Config | ||
run: | | ||
git config user.name "Github Actions" | ||
git config user.email "<[email protected]>" | ||
publish: | ||
name: Publish to Test PyPI | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
# if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
environment: | ||
name: testpypi | ||
url: https://test.pypi.org/p/bing-rewards | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: bing-rewards | ||
path: dist/ | ||
|
||
- name: Create Github Release | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: "${{ env.version }}" | ||
prerelease: ${{ steps.check-version.outputs.prerelease == 'true' }} | ||
draft: true | ||
files: | | ||
dist/* | ||
- name: Publish to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
- name: Publish to Test PyPI | ||
if: ${{ inputs.testing }} | ||
env: | ||
POETRY_TEST_PYPI_TOKEN: ${{ secrets.PYPI_TESTING_API_TOKEN }} | ||
run: | | ||
poetry config repositories.testpypi "https://test.pypi.org/legacy/" | ||
poetry config pypi-token.testpypi $POETRY_TEST_PYPI_TOKEN | ||
poetry publish -r testpypi | ||
release: | ||
name: Create Github Release | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
if: startsWith(github.ref, 'refs/tags/') | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Publish to PyPI | ||
if: ${{ ! inputs.testing && (steps.check-version.outputs.prerelease != 'true') }} | ||
env: | ||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} | ||
run: | | ||
poetry publish | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: bing-rewards | ||
path: dist/ | ||
|
||
- name: Bump Dev Version | ||
if: ${{ ! inputs.testing }} | ||
run: | | ||
git checkout develop | ||
git merge origin/master --no-ff | ||
poetry version minor | ||
git add pyproject.toml | ||
git commit -m "[skip ci] Bump version to v$(poetry version --short)" --no-verify | ||
git push origin develop | ||
- name: Create Github Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
files: dist/ |
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
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