Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions .github/actions/build-and-publish/action.yml

This file was deleted.

25 changes: 21 additions & 4 deletions .github/workflows/actions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@
# Docs: https://gh.io/actions-lockfile
version: 'v0.0.2'
workflows:
'.github/workflows/cd-release.yml':
'.github/workflows/main-workflow.yml':
- 'actions/checkout@v7.0.1'
- 'actions/setup-python@v7.0.0'
'.github/workflows/reusable-cd-dev.yml':
'.github/workflows/release.yml':
- 'actions/checkout@v7.0.1'
- 'actions/setup-python@v7.0.0'
'.github/workflows/reusable-ci.yml':
- 'actions/checkout@v5.1.0'
- 'actions/checkout@v6.1.0'
- 'actions/checkout@v7.0.1'
- 'actions/setup-python@v7.0.0'
- 'codecov/codecov-action@v7.1.1'
'.github/workflows/reusable-deb-build.yml':
- 'actions/checkout@v7.0.1'
- 'actions/upload-artifact@v7.0.2'
'.github/workflows/reusable-docs.yml':
- 'actions/checkout@v7.0.1'
- 'actions/setup-python@v7.0.0'
'.github/workflows/reusable-github-release.yml':
- 'actions/checkout@v7.0.1'
- 'actions/download-artifact@v8.0.2'
'.github/workflows/reusable-pypi-publish.yml':
- 'actions/checkout@v7.0.1'
- 'actions/setup-python@v7.0.0'
'.github/workflows/reusable-security.yml':
- 'actions/checkout@v7.0.1'
- 'actions/setup-python@v7.0.0'
Expand All @@ -39,6 +46,11 @@ dependencies:
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
owner_id: 44036562
repo_id: 197814629
'actions/download-artifact@v8.0.2':
ref: 'v8.0.2'
commit: 'sha1-9000827ccba6bdab643e8b6fd33ac0654aef8333'
owner_id: 44036562
repo_id: 192626254
'actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd':
ref: 'v8.0.0'
commit: 'sha1-ed597411d8f924073f98dfc5c65a23a2325f34cd'
Expand All @@ -49,6 +61,11 @@ dependencies:
commit: 'sha1-5fda3b95a4ea91299a34e894583c3862153e4b97'
owner_id: 44036562
repo_id: 192625525
'actions/upload-artifact@v7.0.2':
ref: 'v7.0.2'
commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9'
owner_id: 44036562
repo_id: 192625955
'codecov/codecov-action@v7.1.1':
ref: 'v7.1.1'
commit: 'sha1-303a32d7a59b442fa8d48b6a1cc6825c09c847a5'
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/cd-release.yml

This file was deleted.

49 changes: 46 additions & 3 deletions .github/workflows/main-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,52 @@ jobs:
contains(github.event.head_commit.modified, 'mkdocs.yml')
uses: ./.github/workflows/reusable-docs.yml

calculate-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0

- name: Calculate dev version
id: version
shell: bash
run: |
# Get latest tag or default to 0.0.0
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
printf "Latest tag: ${LATEST_TAG}\n"

# Remove 'v' prefix if present
LATEST_TAG=${LATEST_TAG#v}

# Parse version components
IFS='.' read -r MAJOR MINOR PATCH <<< "${LATEST_TAG}"

# If no tags found, default to 0.0.0
if [ -z "${MAJOR}" ]; then
MAJOR=0
MINOR=0
PATCH=0
fi

TIMESTAMP=$(date +%Y%m%d%H%M%S)
DEV_VERSION="${MAJOR}.${MINOR}.${PATCH}.dev${TIMESTAMP}"

printf "Dev version: ${DEV_VERSION}\n"
printf "version=${DEV_VERSION}" >> "${GITHUB_OUTPUT}"

cd-dev:
name: CD Dev Publishing
needs: [ci, security, docs]
needs: [ci, security, docs, calculate-version]
if: ${{ !cancelled() }}
uses: ./.github/workflows/reusable-cd-dev.yml
secrets: inherit
uses: $/.github/workflows/reusable-pypi-publish.yml
with:
version: ${{ needs.calculate-version.outputs.version }}
repository-url: https://test.pypi.org/legacy/
install-url: https://test.pypi.org/simple/
environment-name: test-pypi
secrets:
PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
123 changes: 123 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# This workflow is managed by gh actions-lock.

name: Release

on:
workflow_dispatch:
inputs:
version:
description: 'Tag name to release (e.g. v1.2.3). Must already exist.'
required: true
type: string
pypi_target:
description: 'PyPI target (none = skip PyPI)'
required: true
default: 'none'
type: choice
options: [none, test, production]
build_deb:
description: 'Build Debian package?'
required: true
default: true
type: boolean
draft_release:
description: 'Create GitHub Release as draft?'
required: true
default: false
type: boolean

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.split.outputs.version }}
tag: ${{ steps.split.outputs.tag }}
pypi_enabled: ${{ steps.split.outputs.pypi_enabled }}
pypi_repo_url: ${{ steps.split.outputs.pypi_repo_url }}
pypi_install_url: ${{ steps.split.outputs.pypi_install_url }}
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0

- name: Verify tag and compute routing
id: split
shell: bash
run: |
TAG="${{ inputs.version }}"

if ! git rev-parse --verify "refs/tags/${TAG}" >/dev/null 2>&1; then
echo "::error::Tag '${TAG}' does not exist. Push it first, then re-run."
exit 1
fi

VERSION="${TAG#v}"
TARGET="${{ inputs.pypi_target }}"

case "$TARGET" in
none)
PYPI_ENABLED=false
REPO_URL=""
INSTALL_URL=""
;;
test)
PYPI_ENABLED=true
REPO_URL="https://test.pypi.org/legacy/"
INSTALL_URL="https://test.pypi.org/simple/"
;;
production)
PYPI_ENABLED=true
REPO_URL="https://upload.pypi.org/legacy/"
INSTALL_URL="https://pypi.org/simple/"
;;
*)
echo "::error::Unknown pypi_target '${TARGET}'"
exit 1
;;
esac

{
echo "tag=${TAG}"
echo "version=${VERSION}"
echo "pypi_enabled=${PYPI_ENABLED}"
echo "pypi_repo_url=${REPO_URL}"
echo "pypi_install_url=${INSTALL_URL}"
} >> "$GITHUB_OUTPUT"

pypi:
needs: prepare
if: needs.prepare.outputs.pypi_enabled == 'true'
uses: $/.github/workflows/reusable-pypi-publish.yml
with:
version: ${{ needs.prepare.outputs.version }}
repository-url: ${{ needs.prepare.outputs.pypi_repo_url }}
install-url: ${{ needs.prepare.outputs.pypi_install_url }}
environment-name: ${{ inputs.pypi_target == 'test' && 'test-pypi' || 'pypi' }}
secrets:
PYPI_API_TOKEN: ${{ inputs.pypi_target == 'test' && secrets.TEST_PYPI_API_TOKEN || secrets.PYPI_API_TOKEN }}

deb:
needs: prepare
if: inputs.build_deb
uses: $/.github/workflows/reusable-deb-build.yml
with:
version: ${{ needs.prepare.outputs.version }}

release:
needs: [prepare, pypi, deb]
if: |
always() && !cancelled() &&
needs.prepare.result == 'success' &&
(needs.prepare.outputs.pypi_enabled == 'false' || needs.pypi.result == 'success') &&
(inputs.build_deb == false || needs.deb.result == 'success')
permissions:
contents: write
uses: $/.github/workflows/reusable-github-release.yml
with:
version: ${{ needs.prepare.outputs.version }}
tag: ${{ needs.prepare.outputs.tag }}
draft: ${{ inputs.draft_release }}
pypi_published: ${{ needs.prepare.outputs.pypi_enabled == 'true' }}
deb_attached: ${{ inputs.build_deb && needs.deb.result == 'success' }}
package_name: tftp_router_flasher
secrets: inherit
53 changes: 0 additions & 53 deletions .github/workflows/reusable-cd-dev.yml

This file was deleted.

Loading
Loading