Skip to content

Commit

Permalink
Update release action
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtvs committed Sep 21, 2024
1 parent 8e89b40 commit 6ac1c5b
Showing 1 changed file with 19 additions and 52 deletions.
71 changes: 19 additions & 52 deletions .github/workflows/release_n_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,19 @@ jobs:
run: twine check dist/*

- name: Upload package artifacts
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: package-artifacts
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@v1
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/

# Sleep for some seconds to give Test PyPI time to update the search index
- name: Sleep for 120 seconds
uses: jakejarvis/wait-action@master
with:
time: '120s'
- name: Sleep for 120 seconds to give Test PyPI time to update the search index
run: sleep 120

verify-test-pypi:
name: Install from Test PyPI
Expand All @@ -66,13 +62,16 @@ jobs:
- name: Get release version
id: release_version
run: |
echo ::set-output name=number::${GITHUB_REF#refs/*/}
echo ${{ steps.release_version.outputs.number }}
echo "version=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT"
echo ${{ steps.release_version.outputs.version }}
- name: Install torch-lr-finder ${{ steps.release_version.outputs.number }} from Test PyPI
- name: Install torch-lr-finder ${{ steps.release_version.outputs.version }} from Test PyPI
run: |
python -m pip install --upgrade pip
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple torch-lr-finder==${{ steps.release_version.outputs.number }}
pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
torch-lr-finder==${{ steps.release_version.outputs.version }}
release:
name: Create Release
Expand All @@ -83,43 +82,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

# We need the whole history so we can later generate the release notes from the commit logs
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow

# Generate draft release notes by taking the commit logs between this release and the previous
- name: Generate draft release notes
id: release_notes
run: |
# Get the whole commit log with a pretty and easy to post-process format
notes="$(git log --pretty=format:' -%d%Creset %s' --abbrev-commit)"
# Get commit logs between this tag and the previous one
notes="$(awk '/tag: v/ { flag=!flag; count+=1; next } flag && count < 2 {print}' <<< "$notes")"
# Remove all merge commits for a cleaner log
notes="$(sed '/Merge pull request #/d' <<< "$notes")"
# Some weird string replacements to escape special characters...blame GitHub
# for this https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/td-p/37870
notes="${notes//'%'/'%25'}"
notes="${notes//$'\n'/'%0A'}"
notes="${notes//$'\r'/'%0D'}"
echo "::set-output name=content::$notes"
- name: Create draft release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Release notes:
${{ steps.release_notes.outputs.content }}
draft: true
prerelease: false
- name: Create draft release
run: |
gh release create ${{ github.ref }} \
--title "Release ${{ github.ref }}" \
--generate-notes \
--draft
deploy-pypi:
name: Deploy to PyPI
Expand All @@ -128,13 +96,12 @@ jobs:

steps:
- name: Download package artifacts
uses: actions/download-artifact@master
uses: actions/download-artifact@v4
with:
name: package-artifacts
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@v1
with:
user: __token__
password: ${{ secrets.pypi_password }}

0 comments on commit 6ac1c5b

Please sign in to comment.