misc workflow update [no-bump] #81
This file contains hidden or 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
| name: ci/cd | |
| on: | |
| push: | |
| branches: [ '**' ] | |
| tags-ignore: [ '**' ] | |
| jobs: | |
| py-versions: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.versions.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.sha }} # lock to triggered commit ('github.ref' is dynamic) | |
| - id: versions | |
| uses: WIPACrepo/[email protected] | |
| ############################################################################ | |
| # LINTERS | |
| ############################################################################ | |
| flake8: | |
| needs: [ py-versions ] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| py3: ${{ fromJSON(needs.py-versions.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.sha }} # lock to triggered commit ('github.ref' is dynamic) | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.py3 }} | |
| - uses: WIPACrepo/[email protected] | |
| with: | |
| max-complexity: 10 # ideal is ~10-15 | |
| mypy: | |
| needs: [ py-versions ] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| py3: ${{ fromJSON(needs.py-versions.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.sha }} # lock to triggered commit ('github.ref' is dynamic) | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.py3 }} | |
| - uses: WIPACrepo/[email protected] | |
| ############################################################################ | |
| # PACKAGING | |
| ############################################################################ | |
| # writable-branch-detect: | |
| # runs-on: ubuntu-latest | |
| # outputs: | |
| # OKAY: ${{ steps.detect.outputs.OKAY }} | |
| # steps: | |
| # - name: is this a bot-writable branch? | |
| # id: detect | |
| # # dependabot can't access normal secrets | |
| # # & don't run non-branch triggers (like tags) | |
| # # & we don't want to trigger an update on PR's merge to main/master/default (which is a branch) | |
| # run: | | |
| # set -euo pipefail | |
| # echo "now: $(date -u +"%Y-%m-%dT%H:%M:%S.%3N")" | |
| # if [[ \ | |
| # ${{github.actor}} != 'dependabot[bot]' && \ | |
| # ${{github.ref_type}} == 'branch' && \ | |
| # ${{format('refs/heads/{0}', github.event.repository.default_branch)}} != ${{github.ref}} \ | |
| # ]]; then | |
| # echo "OKAY=true" >> "$GITHUB_OUTPUT" | |
| # echo "yes, this branch is compatible" | |
| # else | |
| # echo "OKAY=false" >> "$GITHUB_OUTPUT" | |
| # echo "no, this branch is incompatible" | |
| # fi | |
| py-setup: | |
| # needs: [ writable-branch-detect ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # if: needs.writable-branch-detect.outputs.OKAY == 'true' | |
| with: | |
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
| ref: ${{ github.sha }} # lock to triggered commit ('github.ref' is dynamic) | |
| - uses: WIPACrepo/wipac-dev-py-setup-action@scm | |
| # if: needs.writable-branch-detect.outputs.OKAY == 'true' | |
| with: | |
| pypi_name: 'wipac-dev-actions-testbed' | |
| python_min: 3.12 | |
| author: WIPAC Developers | |
| author_email: [email protected] | |
| keywords_comma: "WIPAC, CI/CD, gitops, testbed" | |
| auto_mypy_option: True | |
| py-dependencies: | |
| # needs: [ writable-branch-detect ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # if: needs.writable-branch-detect.outputs.OKAY == 'true' | |
| with: | |
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
| ref: ${{ github.sha }} # lock to triggered commit ('github.ref' is dynamic) | |
| - uses: WIPACrepo/[email protected] | |
| # if: needs.writable-branch-detect.outputs.OKAY == 'true' | |
| with: | |
| use_directory: true | |
| ############################################################################ | |
| # TESTS | |
| ############################################################################ | |
| ############################################################################ | |
| # TAG NEW VERSION | |
| ############################################################################ | |
| tag-and-release: | |
| # only run on main/master/default | |
| if: format('refs/heads/{0}', github.event.repository.default_branch) == github.ref | |
| needs: [ | |
| py-versions, | |
| flake8, | |
| mypy, | |
| py-setup, | |
| py-dependencies | |
| ] | |
| runs-on: ubuntu-latest | |
| concurrency: release # prevent any possible race conditions | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # required to see tags and commits | |
| ref: ${{ github.sha }} # lock to triggered commit ('github.ref' is dynamic) | |
| - uses: actions/setup-python@v5 # needed for building project | |
| with: | |
| python-version: "${{ fromJSON(needs.py-versions.outputs.matrix)[0] }}" | |
| - uses: WIPACrepo/[email protected] | |
| id: next-version | |
| with: | |
| force-patch-if-no-commit-token: true | |
| ignore-paths: | | |
| .gitignore | |
| assets/** | |
| dependencies-logs/** | |
| resources/foo/** | |
| - if: steps.next-version.outputs.version != '' | |
| name: Tag New Version | |
| run: | | |
| set -euo pipefail | |
| echo "now: $(date -u +"%Y-%m-%dT%H:%M:%S.%3N")" | |
| git tag v${{ steps.next-version.outputs.version }} # note: prepend 'v' | |
| git push origin --tags | |
| - if: steps.next-version.outputs.version != '' | |
| uses: WIPACrepo/[email protected] | |
| # -> uses the most recent git tag for versioning | |
| # -> creates 'dist/' files | |
| - if: steps.next-version.outputs.version != '' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/* | |
| tag_name: v${{ steps.next-version.outputs.version }} # must match git tag above | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - if: steps.next-version.outputs.version != '' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_TOKEN }} |