Skip to content

Commit c1dd46a

Browse files
committed
Add "release" stage
1 parent f0747c3 commit c1dd46a

File tree

1 file changed

+74
-1
lines changed

1 file changed

+74
-1
lines changed

.github/workflows/build.yaml

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build & Test
1+
name: Build, Test, Release
22

33
on:
44
workflow_dispatch:
@@ -47,3 +47,76 @@ jobs:
4747
- name: Test
4848
run: |
4949
poetry run pytest
50+
51+
release:
52+
name: Release, Python ${{ matrix.python-version }}
53+
needs: build
54+
runs-on: ubuntu-latest
55+
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
56+
strategy:
57+
matrix:
58+
python-version: [ '3.11' ]
59+
environment:
60+
name: PyPI
61+
url: https://pypi.org/p/ongoing-process-state
62+
permissions:
63+
id-token: write
64+
contents: write
65+
packages: write
66+
steps:
67+
- uses: actions/checkout@v3
68+
with:
69+
fetch-depth: 0
70+
71+
- uses: actions/setup-python@v3
72+
with:
73+
python-version: ${{ matrix.python-version }}
74+
architecture: x64
75+
76+
- name: Install poetry
77+
shell: bash
78+
run: pip install poetry
79+
80+
- name: Install project
81+
run: |
82+
poetry install
83+
84+
- name: Build
85+
run: |
86+
poetry build
87+
88+
- name: Get version
89+
id: get_version
90+
run: |
91+
echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT"
92+
93+
- name: Upload artifacts
94+
uses: actions/upload-artifact@v3
95+
with:
96+
name: ongoing-process-state-${{ steps.get_version.outputs.version }}-py${{ matrix.python-version }}
97+
path: dist
98+
99+
- name: Generate changelog
100+
run: |
101+
echo "# Changelog" > CHANGELOG.md
102+
echo "" >> CHANGELOG.md
103+
echo "\`\`\`" >> CHANGELOG.md
104+
git log --pretty=format:"%h - %s (%an)" $(git describe --tags --abbrev=0)..HEAD >> CHANGELOG.md
105+
echo "" >> CHANGELOG.md
106+
echo "\`\`\`" >> CHANGELOG.md
107+
108+
- name: Assign repository tag
109+
run: |
110+
git tag ${{ steps.get_version.outputs.version }}
111+
git push --tags
112+
113+
- name: Create release
114+
uses: softprops/action-gh-release@v1
115+
with:
116+
files: |
117+
dist/*
118+
tag_name: ${{ steps.get_version.outputs.version }}
119+
body_path: CHANGELOG.md
120+
121+
- name: Publish to PyPI
122+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)