Skip to content

Commit a9c8cf3

Browse files
pvitalGSVarsha
authored andcommitted
ci: Automate package release and publish.
This commit adds automation to release and publish into GitHub and PyPI.org any new package version based on the creation of a new tag. Signed-off-by: Paulo Vital <[email protected]>
1 parent 8db8cab commit a9c8cf3

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/pkg_release.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Release new version
10+
11+
on:
12+
push:
13+
tags:
14+
- v3.*
15+
16+
jobs:
17+
build:
18+
name: Build package
19+
runs-on: ubuntu-latest
20+
if: ${{ startsWith(github.ref_name, 'v0') }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version-file: "pyproject.toml"
27+
- name: Install pip/build
28+
run: |
29+
python3 -m pip install --upgrade pip
30+
python3 -m pip install build --user
31+
- name: Build a binary wheel and a source tarball
32+
run: python3 -m build
33+
- name: Store the distribution packages
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: python-package-distributions-${{ github.ref_name }}
37+
path: dist/
38+
39+
github-release:
40+
name: Release on GitHub
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: write # IMPORTANT: mandatory for making GitHub Releases
44+
needs:
45+
- build
46+
steps:
47+
- name: Download artifacts
48+
uses: actions/download-artifact@v4
49+
with:
50+
name: python-package-distributions-${{ github.ref_name }}
51+
path: dist/
52+
- name: Create GitHub Release
53+
env:
54+
GITHUB_TOKEN: ${{ github.token }}
55+
run: >-
56+
gh release create
57+
'${{ github.ref_name }}'
58+
dist/**
59+
--repo '${{ github.repository }}'
60+
--title '${{ github.ref_name }}'
61+
--generate-notes
62+
--latest
63+
--verify-tag
64+
65+
publish-to-pypi:
66+
name: Publish to PyPI
67+
needs:
68+
- build
69+
runs-on: ubuntu-latest
70+
environment:
71+
name: pypi
72+
url: https://pypi.org/p/instana/
73+
permissions:
74+
id-token: write # IMPORTANT: mandatory for trusted publishing
75+
steps:
76+
- name: Download artifacts
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: python-package-distributions-${{ github.ref_name }}
80+
path: dist/
81+
- name: Publish to PyPI
82+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)