Skip to content

Commit

Permalink
Added new workflows
Browse files Browse the repository at this point in the history
- 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
coordt committed Apr 13, 2023
1 parent f3b7a0f commit a9cac5b
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

### Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.
Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen.

### What I Did

Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/bumpversion.yaml
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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
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:
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/release.yaml
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 }}

0 comments on commit a9cac5b

Please sign in to comment.