Skip to content

Commit b6dd635

Browse files
committed
adding release
1 parent 5ee49cc commit b6dd635

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

.github/workflows/release.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# REF: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#the-whole-ci-cd-workflow
2+
name: publish release
3+
4+
on:
5+
# run this workflow when manually triggered
6+
workflow_dispatch:
7+
inputs:
8+
part:
9+
description: "Semver part to bump (major, minor, patch)"
10+
type: choice
11+
required: true
12+
default: "patch"
13+
options: ["major", "minor", "patch"]
14+
dry-run:
15+
description: "Dry run"
16+
type: boolean
17+
required: true
18+
default: true
19+
skip-tests:
20+
description: "Skip tests"
21+
type: boolean
22+
required: true
23+
default: false
24+
25+
jobs:
26+
test:
27+
name: Run tests
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Run tests
31+
if: ${{ github.event.inputs.skip-tests == 'false' }}
32+
uses: ./.github/workflows/dev.yml
33+
- name: Skip tests
34+
if: ${{ github.event.inputs.skip-tests == 'true' }}
35+
run: echo "Skipping tests"
36+
37+
bump:
38+
name: Bump version
39+
runs-on: ubuntu-latest
40+
needs: test
41+
outputs:
42+
VERSION: ${{ steps.get-version.outputs.VERSION }}
43+
SHORT_VERSION: ${{ steps.get-version.outputs.SHORT_VERSION }}
44+
MAJOR_VERSION: ${{ steps.get-version.outputs.MAJOR_VERSION }}
45+
MINOR_VERSION: ${{ steps.get-version.outputs.MINOR_VERSION }}
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
- name: Get tags
50+
run: git fetch --tags origin
51+
- name: Configure git for github-actions[bot]
52+
run: |
53+
git config --global user.name "github-actions[bot]"
54+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
55+
- name: Install Python
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: "3.11"
59+
- name: Install Twine
60+
run: pip install twine
61+
- name: Install bumpversion
62+
run: pip install bumpversion
63+
- name: Bump version with bumpversion
64+
run: |
65+
bumpversion ${{ github.event.inputs.part }}
66+
- name: Commit and push with tags
67+
if: ${{ github.event.inputs.dry-run == 'false' }}
68+
run: git push --follow-tags
69+
- name: Get version
70+
id: get-version
71+
run: |
72+
73+
version="$(git describe --tags)"
74+
# remove the leading v from version
75+
version="${version:1}"
76+
echo "VERSION=$version" >> $GITHUB_OUTPUT
77+
major_version="$(cut -d '.' -f 1 <<< $version)"
78+
echo "MAJOR_VERSION=$major_version" >> $GITHUB_OUTPUT
79+
minor_version="$(cut -d '.' -f 2 <<< $version)"
80+
echo "MINOR_VERSION=$minor_version" >> $GITHUB_OUTPUT
81+
short_version="$major_version.$minor_version"
82+
echo "SHORT_VERSION=$short_version" >> $GITHUB_OUTPUT
83+
- name: Show short version
84+
run: echo ${{ steps.get-version.outputs.SHORT_VERSION }}
85+
86+
build:
87+
name: Build distribution
88+
runs-on: ubuntu-latest
89+
needs: bump
90+
91+
steps:
92+
- name: Show version
93+
run: echo ${{ needs.bump.outputs.VERSION }}
94+
- uses: actions/checkout@v4
95+
with:
96+
# want this to be the version that was just bumped
97+
ref: main
98+
- name: Set up Python
99+
uses: actions/setup-python@v5
100+
with:
101+
python-version: "3.11"
102+
- name: build sdist
103+
run: python setup.py sdist
104+
- name: Store the distribution packages
105+
uses: actions/upload-artifact@v3
106+
with:
107+
name: python-package-distributions
108+
path: dist/
109+
110+
publish-to-pypi:
111+
name: Publish to PyPI
112+
needs: build
113+
runs-on: ubuntu-latest
114+
environment:
115+
name: pypi
116+
url: https://pypi.org/p/networkframe
117+
permissions:
118+
id-token: write # IMPORTANT: mandatory for trusted publishing
119+
120+
steps:
121+
- name: Download all the dists
122+
uses: actions/download-artifact@v3
123+
with:
124+
name: python-package-distributions
125+
path: dist/
126+
- name: Publish distribution to PyPI
127+
if: ${{ github.event.inputs.dry-run == 'false' }}
128+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)