diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..3be3147 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,85 @@ +# 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@v5 + 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@v5 + - name: "Download all the dists" + uses: actions/download-artifact@v5 + 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@v5 + with: + name: distfiles + path: dist/ + - name: "Publish to PyPI" + uses: pypa/gh-action-pypi-publish@release/v1 + permissions: + id-token: write diff --git a/pyproject.toml b/pyproject.toml index a05686d..6a114fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,8 +3,8 @@ [project] name = "postgresql-charms-single-kernel" -dynamic = ["version"] description = "Shared and reusable code for PostgreSQL-related charms" +version = "0.0.1" readme = "README.md" license = "Apache-2.0" authors = [