-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added bumpversion.yaml to increase the version when a PR is closed - Added release.yaml to create a github relase and upload things to PyPI
- Loading branch information
Showing
4 changed files
with
145 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Auto-bump the version | ||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: [master] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
bumpversion: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
cache: 'pip' # caching pip dependencies | ||
|
||
- name: Install requirements | ||
run: | | ||
python -m pip install generate-changelog | ||
python -m pip install -e . | ||
- name: Git check | ||
run: | | ||
git config --global user.email "bump-my-version@github.actions" | ||
git config --global user.name "Testing Git" | ||
git --version | ||
git config --list | ||
- name: Generate the changelog and get the release hint | ||
id: generate-changelog | ||
run: | | ||
INFO=$(generate-changelog --output all) | ||
RELEASE_KIND=$(echo "$INFO" | jq -r '.release_hint') | ||
NOTES=$(echo "$INFO" | jq -r '.notes') | ||
NOTES="${NOTES//'%'/'%25'}" | ||
NOTES="${NOTES//$'\\n'/'%0A'}" | ||
NOTES="${NOTES//$'\n'/'%0A'}" | ||
NOTES="${NOTES//$'\r'/'%0D'}" | ||
echo "::notice::Suggested release type is: ${RELEASE_KIND}" | ||
echo "RELEASE_KIND=$RELEASE_KIND" >> $GITHUB_ENV | ||
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT | ||
echo "NOTES=$NOTES" >> $GITHUB_ENV | ||
echo "notes=$NOTES" >> $GITHUB_OUTPUT | ||
echo $NOTES >> release-notes.md | ||
- name: Archive production artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: release-notes.md | ||
path: release-notes.md | ||
|
||
- name: Bump Version | ||
shell: bash | ||
run: | | ||
if [[ $RELEASE_KIND != "no-release" ]]; then | ||
bump-my-version -v "$RELEASE_KIND" | ||
git push | ||
git push --tags | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
name: CI | ||
|
||
on: | ||
- pull_request | ||
pull_request: | ||
types: [opened, synchronize] | ||
branches: [master] | ||
|
||
defaults: | ||
run: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: ["*"] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
# Package when a new tag is pushed | ||
build-package: | ||
if: startsWith(github.ref, 'refs/tags/') | ||
needs: bumpversion | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Package | ||
uses: hynek/build-and-inspect-python-package@v1 | ||
|
||
# Create a GitHub release | ||
release: | ||
name: Create a GitHub release | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
needs: build-package | ||
steps: | ||
- name: Download packages built by build-and-inspect-python-package | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: Packages | ||
path: dist | ||
- name: Download release notes | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: release-notes.md | ||
path: release-notes.md | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body_path: release-notes.md | ||
files: dist/* | ||
|
||
# Upload to Test PyPI. | ||
release-test-pypi: | ||
name: Publish in-dev package to test.pypi.org | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
needs: build-package | ||
steps: | ||
- name: Download packages built by build-and-inspect-python-package | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: Packages | ||
path: dist | ||
|
||
- name: Upload package to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
# Upload to real PyPI on GitHub Releases. | ||
release-pypi: | ||
name: Publish released package to pypi.org | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
needs: build-package | ||
steps: | ||
- name: Download packages built by build-and-inspect-python-package | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: Packages | ||
path: dist | ||
|
||
- name: Upload package to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |