Skip to content

Commit 0e28b64

Browse files
authored
[DPE-8030] Publishing workflow (#6)
* Publishing workflow * Run CI before release
1 parent a47b9fa commit 0e28b64

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

.github/workflows/release.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Copyright 2025 Canonical Ltd.
2+
# See LICENSE file for licensing details.
3+
name: Publish
4+
5+
on:
6+
push:
7+
branches:
8+
- 16/edge
9+
10+
concurrency:
11+
# Prevent race conditions (if multiple commits have been pushed since the last release)
12+
group: dpw-release-python-package-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
ci-tests:
17+
name: Tests
18+
uses: ./.github/workflows/ci.yaml
19+
secrets: inherit
20+
build:
21+
name: "Build package"
22+
needs:
23+
- ci-tests
24+
runs-on: ubuntu-latest
25+
outputs:
26+
VERSION: ${{ steps.export.outputs.VERSION }}
27+
steps:
28+
- name: "Checkout"
29+
uses: actions/checkout@v5
30+
with:
31+
fetch-depth: 0
32+
- name: "Install uv"
33+
run: sudo snap install astral-uv --classic
34+
- name: "Export package information"
35+
id: export
36+
run: |
37+
VERSION=$(uv version --short)
38+
if [ "$(git tag -l "${VERSION}")" ]; then
39+
echo "Tag ${VERSION} already exists. Please bump the project to a greater version."
40+
exit 1
41+
fi
42+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
43+
- name: "Build package"
44+
run: uv build
45+
- name: "Store the distribution packages"
46+
uses: actions/upload-artifact@v5
47+
with:
48+
name: distfiles
49+
path: dist/
50+
51+
upload-github:
52+
name: "Publish to GitHub"
53+
needs: [build]
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: "Checkout"
57+
uses: actions/checkout@v5
58+
- name: "Download all the dists"
59+
uses: actions/download-artifact@v5
60+
with:
61+
name: distfiles
62+
path: dist/
63+
- name: "Create GitHub release"
64+
run: |
65+
git tag "${{ needs.build.outputs.VERSION }}"
66+
git push origin "${{ needs.build.outputs.VERSION }}"
67+
gh release create "${{ needs.build.outputs.VERSION }}" --generate-notes --title "${{ needs.build.outputs.VERSION }}"
68+
gh release upload "${{ needs.build.outputs.VERSION }}" dist/*.{tar.gz,whl}
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
72+
upload-pypi:
73+
name: "Publish to PyPI"
74+
needs: [build]
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: "Download all the dists"
78+
uses: actions/download-artifact@v5
79+
with:
80+
name: distfiles
81+
path: dist/
82+
- name: "Publish to PyPI"
83+
uses: pypa/gh-action-pypi-publish@release/v1
84+
permissions:
85+
id-token: write

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
[project]
55
name = "postgresql-charms-single-kernel"
6-
dynamic = ["version"]
76
description = "Shared and reusable code for PostgreSQL-related charms"
7+
version = "0.0.1"
88
readme = "README.md"
99
license = "Apache-2.0"
1010
authors = [

0 commit comments

Comments
 (0)