Skip to content

Commit 0e5de45

Browse files
New release workflow
1 parent c235673 commit 0e5de45

File tree

3 files changed

+74
-136
lines changed

3 files changed

+74
-136
lines changed

.github/workflows/release.yml

Lines changed: 54 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,58 @@
11
name: release
2-
run-name: Release ${{ inputs.VERSION }} (pre-release - ${{ inputs.IS_PRE_RELEASE }}) by @${{ github.actor }} from ${{ github.ref_name }}
2+
run-name: Release by @${{ github.actor }} from ${{ github.ref_name }}
33

4-
on:
5-
workflow_dispatch:
6-
inputs:
7-
VERSION:
8-
description: "The version to release"
9-
required: true
10-
IS_PRE_RELEASE:
11-
description: "It IS a pre-release"
12-
required: true
13-
default: false
14-
type: boolean
4+
on: [push]
155

166
jobs:
17-
bump: # This job is used to bump the version and create a release
18-
runs-on: ubuntu-latest
19-
env:
20-
VERSION: ${{ inputs.VERSION }}
21-
GH_TOKEN: ${{ github.token }}
22-
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
23-
permissions:
24-
contents: write
25-
steps:
26-
- name: set up Python
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: "3.12"
30-
31-
- name: install dependencies
32-
run: |
33-
pip install --upgrade pip
34-
pip install build hatch
35-
36-
- name: configure git with the bot credentials
37-
run: |
38-
mkdir -p ~/.ssh
39-
ssh-keyscan github.com >> ~/.ssh/known_hosts
40-
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
41-
ssh-add - <<< "${{ secrets.NEXTMVBOT_SSH_KEY }}"
42-
43-
echo "${{ secrets.NEXTMVBOT_SIGNING_KEY }}" > ~/.ssh/signing.key
44-
chmod 600 ~/.ssh/signing.key
45-
46-
git config --global user.name "nextmv-bot"
47-
git config --global user.email "[email protected]"
48-
git config --global gpg.format ssh
49-
git config --global user.signingkey ~/.ssh/signing.key
50-
51-
git clone [email protected]:nextmv-io/nextplot.git
52-
53-
- name: upgrade version with hatch
54-
run: hatch version ${{ env.VERSION }}
55-
working-directory: ./nextplot
56-
57-
- name: commit new version
58-
run: |
59-
git add nextplot/__about__.py
60-
git commit -S -m "Bump version to $VERSION"
61-
git push
62-
git tag $VERSION
63-
git push origin $VERSION
64-
working-directory: ./nextplot
65-
66-
- name: create release
67-
run: |
68-
PRERELEASE_FLAG=""
69-
if [ ${{ inputs.IS_PRE_RELEASE }} = true ]; then
70-
PRERELEASE_FLAG="--prerelease"
71-
fi
72-
73-
gh release create $VERSION \
74-
--verify-tag \
75-
--generate-notes \
76-
--title $VERSION $PRERELEASE_FLAG
77-
working-directory: ./nextplot
78-
79-
- name: ensure passing build
80-
run: python -m build
81-
working-directory: ./nextplot
82-
83-
release: # This job is used to publish the release to PyPI/TestPyPI
84-
runs-on: ubuntu-latest
85-
needs: bump
86-
strategy:
87-
matrix:
88-
include:
89-
- target-env: pypi
90-
target-url: https://pypi.org/p/nextplot
91-
- target-env: testpypi
92-
target-url: https://test.pypi.org/p/nextplot
93-
environment:
94-
name: ${{ matrix.target-env }}
95-
url: ${{ matrix.target-url }}
96-
permissions:
97-
contents: read
98-
id-token: write # This is required for trusted publishing to PyPI
99-
steps:
100-
- name: git clone develop
101-
uses: actions/checkout@v4
102-
with:
103-
ref: develop
104-
105-
- name: set up Python
106-
uses: actions/setup-python@v5
107-
with:
108-
python-version: "3.12"
109-
110-
- name: install dependencies
111-
run: |
112-
pip install --upgrade pip
113-
pip install build hatch
114-
115-
- name: build binary wheel and source tarball
116-
run: python -m build
117-
118-
- name: Publish package distributions to PyPI
119-
if: ${{ matrix.target-env == 'pypi' }}
120-
uses: pypa/gh-action-pypi-publish@release/v1
121-
with:
122-
packages-dir: ./dist
123-
124-
- name: Publish package distributions to TestPyPI
125-
if: ${{ matrix.target-env == 'testpypi' }}
126-
uses: pypa/gh-action-pypi-publish@release/v1
127-
with:
128-
repository-url: https://test.pypi.org/legacy/
129-
packages-dir: ./dist
130-
131-
notify:
132-
runs-on: ubuntu-latest
133-
needs: release
134-
if: ${{ needs.release.result == 'success' && inputs.IS_PRE_RELEASE == false }}
135-
steps:
136-
- name: notify slack
137-
run: |
138-
export DATA="{\"text\":\"Release notification - nextplot ${{ inputs.VERSION }} (see <https://github.com/nextmv-io/nextplot/releases/${{ inputs.VERSION }}|release notes> / <https://pypi.org/project/nextplot|PyPI>)\"}"
139-
curl -X POST -H 'Content-type: application/json' --data "$DATA" ${{ secrets.SLACK_URL_MISSION_CONTROL }}
7+
release:
8+
if: ${{ github.ref_type == 'branch' }}
9+
uses: nextmv-io/release/.github/workflows/release.yml@develop
10+
with:
11+
BRANCH: ${{ github.ref_name }}
12+
REPOSITORY: nextplot
13+
LANGUAGE: python
14+
PACKAGE_NAME: nextplot
15+
PACKAGE_LOCATION: .
16+
VERSION_FILE: __about__.py
17+
secrets: inherit
18+
19+
publish: # Unfortunately, PyPI publishing does not support reusable workflows, so we must publish here.
20+
needs: release
21+
if: ${{ needs.release.outputs.RELEASE_NEEDED == 'true' }}
22+
runs-on: ubuntu-latest
23+
environment:
24+
name: pypi
25+
url: https://pypi.org/p/nextpipe
26+
permissions:
27+
id-token: write # This is required for trusted publishing to PyPI
28+
steps:
29+
- name: git clone ${{ github.ref_name }}
30+
uses: actions/checkout@v4
31+
with:
32+
ref: ${{ github.ref_name }}
33+
34+
- name: set up Python
35+
uses: actions/setup-python@v5
36+
37+
- name: install dependencies
38+
run: |
39+
pip install --upgrade pip
40+
pip install build hatch
41+
42+
- name: python - build binary wheel and source tarball
43+
run: python -m build
44+
45+
- name: python - publish package distributions to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1
47+
with:
48+
packages-dir: ./dist
49+
50+
notify:
51+
needs: [release, publish]
52+
if: ${{ needs.release.outputs.RELEASE_NEEDED == 'true' && needs.release.outputs.SHOULD_NOTIFY_SLACK == 'true' }}
53+
uses: nextmv-io/release/.github/workflows/notify-slack.yml@develop
54+
with:
55+
PACKAGE_NAME: nextplot
56+
VERSION: ${{ needs.release.outputs.VERSION }}
57+
REPOSITORY: nextplot
58+
secrets: inherit

RELEASE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Release
2+
3+
A reusable workflow is used to release the package. Nextmv team members: please
4+
go to the corresponding repository for more information.
5+
6+
## Stable release
7+
8+
Open a PR against the `develop` branch with the following change:
9+
10+
* Update the version in the `nextplot/__about__.py` file.
11+
12+
After the PR is merged, the `release.yml` workflow will be triggered and it
13+
will automatically create a release and publish the package to PyPI.
14+
15+
## Pre-release
16+
17+
Update the version in the `nextplot/__about__.py` file to a dev tag. When a
18+
commit is pushed, the `release.yml` workflow will be triggered and it will
19+
automatically create a release and publish the package to PyPI.

nextplot/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "v0.1.8"
1+
__version__ = "v0.1.9.dev0"

0 commit comments

Comments
 (0)