Skip to content

Release

Release #42

Workflow file for this run

name: Release
permissions:
contents: write
on:
workflow_dispatch:
inputs:
target:
required: true
type: choice
options:
- "TestPyPi"
- "PyPi"
default: "TestPyPi"
jobs:
release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Setup environment
run: |
python3 -m pip install poetry
make venv
make bison BISON_INSTALL_PATH=/tmp/bison-install
echo "/tmp/bison-install/bin" >> ${GITHUB_PATH}
- name: Extract version
id: version
run: |
VERSION=$(poetry version -s)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Create package
run: make package
- name: Publish package (test.pypi.org)
if: github.event.inputs.target== 'TestPyPi'
run: |
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi ${{ secrets.TEST_PYPI_API_TOKEN }}
poetry publish -r test-pypi
- name: Publish package (pypi.org)
if: github.event.inputs.target== 'PyPi'
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
poetry publish
- name: Set up QEMU
if: github.event.inputs.target== 'PyPi'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event.inputs.target== 'PyPi'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
if: github.event.inputs.target== 'PyPi'
id: docker-metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/axosyslog-cfg-helper
tags: type=semver,pattern={{version}},value=v${{ steps.version.outputs.VERSION }}
sep-tags: ','
- name: Build and push container image
if: github.event.inputs.target== 'PyPi'
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}
- name: Publish GitHub Release
if: github.event.inputs.target== 'PyPi'
env:
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
TITLE="${VERSION}"
DESCRIPTION="Generated for [AxoSyslog $(make print-axosyslog-version)]($(make print-axosyslog-release-url))."
TAG="${VERSION}"
TARBALL="dist/axosyslog_cfg_helper-${VERSION}.tar.gz"
gh release create \
--title "${TITLE}" \
--notes "${DESCRIPTION}" \
"${TAG}" \
"${TARBALL}"