Skip to content

Update actions/checkout action to v6 (#44) #39

Update actions/checkout action to v6 (#44)

Update actions/checkout action to v6 (#44) #39

Workflow file for this run

# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.
name: Publish
on:
push:
branches:
- 16/edge
concurrency:
# Prevent race conditions (if multiple commits have been pushed since the last release)
group: dpw-release-python-package-${{ github.ref }}
cancel-in-progress: true
jobs:
ci-tests:
name: Tests
uses: ./.github/workflows/ci.yaml
secrets: inherit
build:
name: "Build package"
needs:
- ci-tests
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.export.outputs.VERSION }}
steps:
- name: "Checkout"
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: "Install uv"
run: sudo snap install astral-uv --classic
- name: "Export package information"
id: export
run: |
VERSION=$(uv version --short)
if [ "$(git tag -l "${VERSION}")" ]; then
echo "Tag ${VERSION} already exists. Please bump the project to a greater version."
exit 1
fi
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: "Build package"
run: uv build
- name: "Store the distribution packages"
uses: actions/upload-artifact@v5
with:
name: distfiles
path: dist/
upload-github:
name: "Publish to GitHub"
needs: [build]
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v6
- name: "Download all the dists"
uses: actions/download-artifact@v6
with:
name: distfiles
path: dist/
- name: "Create GitHub release"
run: |
git tag "${{ needs.build.outputs.VERSION }}"
git push origin "${{ needs.build.outputs.VERSION }}"
gh release create "${{ needs.build.outputs.VERSION }}" --generate-notes --title "${{ needs.build.outputs.VERSION }}"
gh release upload "${{ needs.build.outputs.VERSION }}" dist/*.{tar.gz,whl}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload-pypi:
name: "Publish to PyPI"
needs: [build]
runs-on: ubuntu-latest
steps:
- name: "Download all the dists"
uses: actions/download-artifact@v6
with:
name: distfiles
path: dist/
- name: "Publish to PyPI"
uses: pypa/gh-action-pypi-publish@release/v1
permissions:
id-token: write