Skip to content

Merge pull request #3 from hacktegic/dependabot/github_actions/action… #6

Merge pull request #3 from hacktegic/dependabot/github_actions/action…

Merge pull request #3 from hacktegic/dependabot/github_actions/action… #6

Workflow file for this run

name: trunk
on:
push:
workflow_dispatch:
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
outputs:
version-changed: ${{ steps.changes.outputs.version }}
steps:
- uses: actions/checkout@v6
- uses: psf/black@stable
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: 'pip'
- name: Install hatch
run: >-
python3 -m
pip install
hatch
- name: Run tests
run: hatch test || exit 0
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
version:
- 'src/nmapp/__about__.py'
build:
name: Build Python Wheel 📦
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && needs.test.outputs.version-changed == 'true'
needs:
- test
outputs:
our-version-major: ${{ steps.our-version-major.outputs.version }}
our-version-minor: ${{ steps.our-version-minor.outputs.version }}
our-version-full: ${{ steps.our-version-full.outputs.version }}
steps:
- uses: actions/checkout@v6
- id: our-version-major
run: |
echo version=$(grep -oP '(?<=__version__ = ")[^"]*' src/nmapp/__about__.py | cut -d '.' -f 1) >> $GITHUB_OUTPUT
- id: our-version-minor
run: |
echo version=$(grep -oP '(?<=__version__ = ")[^"]*' src/nmapp/__about__.py | cut -d '.' -f 2) >> $GITHUB_OUTPUT
- id: our-version-full
run: |
echo version=$(grep -oP '(?<=__version__ = ")[^"]*' src/nmapp/__about__.py) >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: 'pip'
- name: Install hatch
run: >-
python3 -m
pip install
hatch
- name: Build a binary wheel and a source tarball
run: hatch build
- name: Store the distribution packages
uses: actions/upload-artifact@v5
with:
name: python-package-distributions
path: dist/
build-and-push-image:
name: Build and push container image to GHCR
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && needs.test.outputs.version-changed == 'true'
needs:
- test
- build
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download all the dists
uses: actions/download-artifact@v6
with:
name: python-package-distributions
path: dist/
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: |
ghcr.io/hacktegic/nmapp:${{ needs.build.outputs.our-version-full }}
ghcr.io/hacktegic/nmapp:${{ needs.build.outputs.our-version-major }}
ghcr.io/hacktegic/nmapp:latest
# publish-to-pypi:
# name: >-
# Publish 📦 to PyPI
# if: github.ref == 'refs/heads/main' && needs.test.outputs.version-changed == 'true'
# needs:
# - test
# - build
# runs-on: ubuntu-latest
# environment:
# name: pypi
# url: https://pypi.org/p/nmapp
# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing
# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v6
# with:
# name: python-package-distributions
# path: dist/
# - name: Publish distribution 📦 to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# packages-dir: dist/
# verbose: true
release:
name: >-
Create GitHub Release
if: github.ref == 'refs/heads/main' && needs.test.outputs.version-changed == 'true'
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- build
- build-and-push-image
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.75.0
env:
CUSTOM_TAG: ${{ needs.build.outputs.our-version-full }}
GITHUB_TOKEN: ${{ github.token }}
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: true
name: ${{ needs.build.outputs.our-version-full }}
tag_name: ${{ needs.build.outputs.our-version-full }}
generate_release_notes: true
token: ${{ github.token }}