Skip to content

Commit cd28c78

Browse files
committed
Automate release process
1 parent 10fd755 commit cd28c78

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

Diff for: .github/workflows/workflow.yml renamed to .github/workflows/lint.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
name: pslab-python
2-
1+
name: lint
32
on:
43
- push
54
- pull_request

Diff for: .github/workflows/publish.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
8+
jobs:
9+
pypi-publish:
10+
runs-on: ubuntu-latest
11+
12+
environment: pypi
13+
14+
permissions:
15+
id-token: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: build wheel and sdist
21+
run: |
22+
pip install flit
23+
flit build
24+
25+
- name: publish
26+
uses: pypa/gh-action-pypi-publish@release/v1

Diff for: .github/workflows/release.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Draft release
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
set-body:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- run: sudo apt install pcregrep
14+
15+
- uses: actions/checkout@v4
16+
17+
- name: Parse changelog
18+
id: parse-changelog
19+
run: |
20+
tag='${{ github.ref_name }}'
21+
re_current_tag="## \[$tag\].*\n\n" # Match, but do not capture, current version tag, then...
22+
re_changes_body='((.|\n)+?)' # capture everything including newlines...
23+
re_previous_tag='## \[[0-9]+.[0-9]+.[0-9]+\]' # until previous version tag.
24+
re_full="${re_current_tag}${re_changes_body}${re_previous_tag}"
25+
echo 'match<<EOF' >> $GITHUB_OUTPUT
26+
# Match multiple lines, output capture group 1.
27+
pcregrep -M -o1 "$re_full" ./CHANGELOG.md >> $GITHUB_OUTPUT
28+
echo 'EOF' >> $GITHUB_OUTPUT
29+
30+
- name: Set release body
31+
uses: softprops/action-gh-release@v2
32+
with:
33+
draft: true
34+
body: ${{ steps.parse-changelog.outputs.match }}

0 commit comments

Comments
 (0)