Skip to content

Bump codecov/codecov-action from 3 to 4 #317

Bump codecov/codecov-action from 3 to 4

Bump codecov/codecov-action from 3 to 4 #317

Workflow file for this run

---
name: Test
on:
push:
branches: [main]
tags: ['v*.*.*']
pull_request:
branches: [main]
jobs:
test:
permissions:
contents: read
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
env:
PYTEST_ADDOPTS: '--color=yes'
outputs:
relver: ${{ steps.setvars.outputs.relver }}
branch: ${{ steps.setvars.outputs.branch }}
changelogver: ${{ steps.setvars.outputs.changelogver }}
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
- name: Requirements
run: |
pip install --upgrade pip setuptools wheel
pip install .[tests]
- name: Pytest
run: pytest tests/
- name: Set vars
id: setvars
run: |
VER_TAG=${GITHUB_REF/refs\/tags\/v/}
echo "relver=${VER_TAG}" | tee --append $GITHUB_OUTPUT
echo "branch=${GITHUB_REF#refs/heads/}" | tee --append $GITHUB_OUTPUT
echo "changelogver=v${VER_TAG//\./-}" | tee --append $GITHUB_OUTPUT
- name: Coverage
uses: codecov/codecov-action@v4
build-container:
permissions:
contents: read
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform: [arm64, amd64]
outputs:
container-description: ${{ steps.description.outputs.container-description }}
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: Set up QEMU
if: matrix.platform == 'arm64'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: matrix.platform == 'arm64'
uses: docker/setup-buildx-action@v3
- name: Build amd64
uses: docker/build-push-action@v5
with:
push: false
context: .
load: true
platforms: linux/${{ matrix.platform }}
tags: galactory:latest
- name: Run container
run: docker run --platform ${{ matrix.platform }} --rm galactory --help
- name: Extract container description
id: description
run: |
DESC=$(docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.description" }}' galactory)
echo "container-description=$DESC" | tee --append $GITHUB_OUTPUT
build-python:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Pre-reqs
run: pip install --upgrade pip setuptools build twine
- name: Build
run: python -m build
- name: Test build
run: python -m twine check dist/*
- name: Check version
id: checkver
if: startsWith(github.ref, 'refs/tags/')
run: |
VER_TAG=${GITHUB_REF/refs\/tags\/v/}
expected_sdist=galactory-${VER_TAG}.tar.gz
expected_wheel=galactory-${VER_TAG}-py3-none-any.whl
if [ ! -f "dist/${expected_sdist}" ] || [ ! -f "dist/${expected_wheel}" ]
then
exit 1
fi
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist
retention-days: ${{ github.event_name == 'push' && 90 || 7 }}
if-no-files-found: error
container_release:
needs: [test, build-container]
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
# ^ checkout
packages: write
# ^ ghcr
env:
UPSTREAM: ghcr.io/${{ github.repository_owner }}/galactory
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to registry
if: github.event_name == 'push'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build & Push
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name == 'push' }}
context: .
platforms: linux/amd64,linux/arm64
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
tags: |
${{ env.UPSTREAM }}:${{ startsWith(github.ref, 'refs/tags/') && 'latest' || needs.test.outputs.branch }}
${{ env.UPSTREAM }}:${{ startsWith(github.ref, 'refs/tags/') && needs.test.outputs.relver || github.sha }}
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ needs.build-container.outputs.container-description }}
pypi_release:
needs: [test, build-python]
if: >-
github.event_name == 'push'
&& startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
id-token: write
# ^ PyPI OIDC
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e
github_release:
needs:
- test
- build-container
- build-python
- container_release
- pypi_release
if: >-
github.event_name == 'push'
&& startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
# ^ GitHub tag and release
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d
with:
generate_release_notes: true
fail_on_unmatched_files: true
files: dist/*
body: |
PyPI: https://pypi.org/project/galactory/${{ needs.test.outputs.relver }}/
Container: `ghcr.io/${{ github.repository }}:${{ needs.test.outputs.relver }}`
Browse container tags: https://github.com/briantist/galactory/pkgs/container/galactory
Changelog: https://github.com/briantist/galactory/blob/main/CHANGELOG.rst#${{ needs.test.outputs.changelogver }}