Bump docker/build-push-action from 5 to 6 (#66) #72
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
name: Build | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- "v*.*.*" | |
paths-ignore: | |
- '**.md' | |
- 'docs/**' | |
pull_request: | |
branches: | |
- 'main' | |
paths-ignore: | |
- '**.md' | |
- 'docs/**' | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
latest_tag: latest | |
jobs: | |
test: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: Lint with Ruff | |
run: | | |
pip install ruff | |
ruff check --output-format=github . | |
continue-on-error: true | |
- name: test | |
run: | | |
pip install -r requirements.txt | |
pip install -r dev_requirements.txt | |
PYTHONPATH=$(pwd) pytest tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov=shadycompass --cov-branch --cov-report=xml:coverage-${{ matrix.python-version }}.xml --cov-report=html:htmlcov/${{ matrix.python-version }} --cov-report=term-missing | |
- name: Upload pytest test results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pytest-results-${{ matrix.python-version }} | |
path: | | |
junit/test-results-${{ matrix.python-version }}.xml | |
coverage-${{ matrix.python-version }}.xml | |
htmlcov/${{ matrix.python-version }} | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} | |
build-and-push-image: | |
runs-on: ubuntu-22.04 | |
needs: [test] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
env: | |
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-exe: | |
name: Build packages | |
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }} | |
needs: [ test ] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
TARGET: linux | |
CMD_BUILD: pyinstaller -p shadycompass --onefile --console --name shadycompass shadycompass.py | |
OUT_FILE_NAME: shadycompass | |
RELEASE_FILE_NAME: shadycompass_${{github.ref_name}}_linux_amd64 | |
ASSET_MIME: application/octet-stream | |
- os: macos-latest | |
TARGET: macos | |
CMD_BUILD: pyinstaller -p shadycompass --onefile --console --name shadycompass shadycompass.py | |
OUT_FILE_NAME: shadycompass | |
RELEASE_FILE_NAME: shadycompass_${{github.ref_name}}_macos | |
ASSET_MIME: application/octet-stream | |
- os: windows-latest | |
TARGET: windows | |
CMD_BUILD: pyinstaller -p shadycompass --onefile --console --name shadycompass shadycompass.py | |
OUT_FILE_NAME: shadycompass.exe | |
RELEASE_FILE_NAME: shadycompass_${{github.ref_name}}.exe | |
ASSET_MIME: application/vnd.microsoft.portable-executable | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install pyinstaller | |
- name: Build with pyinstaller for ${{matrix.TARGET}} | |
run: | | |
${{matrix.CMD_BUILD}} | |
mv ./dist/${{ matrix.OUT_FILE_NAME }} ./dist/${{ matrix.RELEASE_FILE_NAME }} | |
- name: Upload Asset | |
uses: actions/upload-artifact@v4 | |
with: | |
name: exe-${{ matrix.RELEASE_FILE_NAME }} | |
path: ./dist/${{ matrix.RELEASE_FILE_NAME }} | |
if-no-files-found: error | |
pre-release: | |
if: startsWith(github.ref, 'refs/heads/') | |
name: "Pre Release" | |
runs-on: "ubuntu-latest" | |
needs: [ test, build-exe ] | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Update latest tag | |
if: ${{ github.event_name == 'push' }} | |
run: | | |
git tag -d ${{ env.latest_tag }} || true | |
git push origin :refs/tags/${{ env.latest_tag }} || true | |
git tag ${{ env.latest_tag }} | |
git push origin ${{ env.latest_tag }} | |
- name: Download exe | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
pattern: exe-* | |
merge-multiple: true | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: "Development Build" | |
tag_name: ${{ env.latest_tag }} | |
prerelease: true | |
fail_on_unmatched_files: true | |
generate_release_notes: false | |
files: | | |
dist/shadycompass_${{github.ref_name}}_linux_amd64 | |
dist/shadycompass_${{github.ref_name}}_macos | |
dist/shadycompass_${{github.ref_name}}.exe | |
release: | |
if: startsWith(github.ref, 'refs/tags/') | |
name: "Release" | |
runs-on: "ubuntu-latest" | |
needs: [ test, build-exe ] | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download exe | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
pattern: exe-* | |
merge-multiple: true | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
fail_on_unmatched_files: true | |
generate_release_notes: true | |
files: | | |
dist/shadycompass_${{github.ref_name}}_linux_amd64 | |
dist/shadycompass_${{github.ref_name}}_macos | |
dist/shadycompass_${{github.ref_name}}.exe |