forked from py-libhdate/py-libhdate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update the changelog * Move from rst to md for CHANGELOG * Change formatting * Update release flow * Fixup create pull request * No need for auto-commit, create pull request deals with that * Cleanup the drafting template * Add bumpversion configuration * Make workflow manual * Fixup tokens * For PERSONAL ONLY: Use testpypi
- Loading branch information
Showing
5 changed files
with
211 additions
and
114 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
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,43 +1,73 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
inputs: | ||
version_bump: | ||
description: 'Version part to bump (major, minor, patch)' | ||
required: true | ||
default: 'patch' | ||
|
||
jobs: | ||
publish-release: | ||
|
||
if: contains(github.repository_owner.permissions.admins, github.event.sender.login) | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
# Give the default GITHUB_TOKEN write permission to commit and push the | ||
# added or changed files to the repository. | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ssh-key: ${{ secrets.RELEASE_KEY }} | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: pip install bump-my-version | ||
|
||
- name: Get version | ||
- name: Fetch Draft Release Notes | ||
id: fetch_release_notes | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "VERSION=$(/usr/bin/git tag --list | sed 's|.*v\([0-9\.]*\).*|\1|')" >> $GITHUB_ENV | ||
DRAFT_RELEASE=$(gh api repos/${{ github.repository }}/releases -q '[.[] | select(.draft==true)] | first') | ||
DRAFT_NOTES=$(echo $DRAFT_RELEASE | jq -r '.body') | ||
DRAFT_ID=$(echo $DRAFT_RELEASE | jq -r '.id') | ||
echo "::set-output name=notes::$DRAFT_NOTES" | ||
gh api repos/${{ github.repository }}/releases/$DRAFT_ID -X DELETE | ||
- name: Update Changelog | ||
uses: stefanzweifel/changelog-updater-action@v1 | ||
with: | ||
latest-version: ${{ github.event.release.tag_name }} | ||
release-notes: ${{ github.event.release.body }} | ||
|
||
- name: Bump version | ||
run: bump-my-version bump ${{ github.event.inputs.version_bump }} -v | ||
|
||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
sed 's/^version = ".*"/version = "'"$VERSION"'"/' -i pyproject.toml | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git add pyproject.toml | ||
git commit -m "releasing v$VERSION" | ||
git tag -f "v$VERSION" | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Push tags | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
tags: true | ||
force: true | ||
TAG_NAME=$(bump-my-version show current_version) | ||
gh release create v$TAG_NAME --title "Release v$TAG_NAME" --notes "${{ steps.fetch_release_notes.outputs.notes }}" | ||
- name: Set up PDM | ||
uses: pdm-project/setup-pdm@v4 | ||
|
||
- name: Build and publish to pypi | ||
run: pdm publish | ||
run: pdm publish -r testpypi | ||
env: | ||
PDM_PUBLISH_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
PDM_PUBLISH_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} | ||
|
||
- name: Upload the wheel to the Github release | ||
run: | | ||
TAG_NAME=$(bump-my-version show current_version) | ||
pdm build | ||
gh release upload -R ${{ github.repository }} v$TAG_NAME dist/* |
Oops, something went wrong.