From 5e3c001ef1cb84992ccc3b1513b3d3e7087c54ad Mon Sep 17 00:00:00 2001 From: Jesse Talavera Date: Sun, 21 Apr 2024 17:18:06 -0400 Subject: [PATCH] Update the workflows --- .github/workflows/build.yml | 52 ----------------------- .github/workflows/release.yml | 78 +++++++++++++++++++++++++++++------ 2 files changed, 65 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index b78dc7e..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: build - -on: - push: - paths: - - '.github/workflows/build.yml' - - '**/*.py' - branches: - - '**' - tags: - - '!**' - pull_request: - paths: - - '.github/workflows/build.yml' - - '**/*.py' - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: extractions/setup-just@v1 - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - run: just install lint - test: - runs-on: ubuntu-latest - strategy: - matrix: - pythonversion: ['3.8', '3.9', '3.10', '3.11'] - steps: - - uses: actions/checkout@v3 - - uses: extractions/setup-just@v1 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.pythonversion }} - - run: just install coverage - coverage: - if: github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: extractions/setup-just@v1 - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - run: just install coverage - - uses: coverallsapp/github-action@v2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: './coverage.lcov' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 46b03d7..5d36c28 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,23 +1,75 @@ -name: release +name: Build & Release on: + workflow_dispatch: push: - tags: - - '*' + branches: + - main + - dev + pull_request: + branches: + - dev jobs: release: + name: Create Release runs-on: ubuntu-latest + environment: + name: release + url: + ttps://pypi.org/p/libretro.py + permissions: + id-token: write # Required for trusted publishing + steps: - - uses: actions/checkout@v3 - - uses: extractions/setup-just@v1 - - uses: actions/setup-python@v4 + - name: Check Out Source + uses: actions/checkout@v4 + with: + fetch-depth: 0 # To ensure we have all tags + + - name: Install Just + uses: extractions/setup-just@v2 + + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + cache-dependency-path: setup.py + + - name: Install Virtual Environment + run: just install + + - name: Validate Formatting + run: just black-check isort-check + + - name: Validate Security + run: just bandit + + - name: Get Latest Changelog Version + id: changelog + uses: release-flow/keep-a-changelog-action@v3.0.0 with: - python-version: '3.11' + command: query + version: latest + + - name: Get the Newest Tag + id: newest-tag + run: | + echo "version=`git tag --list "v[0-9]*.[0-9]*.[0-9]*" --sort=-v:refname | head -n1 | cut -c2-`" >> "$GITHUB_OUTPUT" + - name: Build package - run: just install build - # Uncomment for your project - # - name: Publish to PyPI - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # password: ${{ secrets.PYPI_API_TOKEN }} + run: just build + # Uses the "build" recipe from the justfile + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@v1.8.14 + if: "${{ steps.changelog.outputs.version != steps.newest-tag.outputs.version }}" + + - name: Create Release + if: "${{ steps.changelog.outputs.version != steps.newest-tag.outputs.version }}" + uses: softprops/action-gh-release@v2.0.4 + with: + token: ${{ secrets.RELEASE_TOKEN }} + tag_name: "v${{ steps.changelog.outputs.version }}" + body: "${{ steps.changelog.outputs.release-notes }}"