Skip to content

Commit

Permalink
Fixed automation. !wip
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Dec 18, 2023
1 parent 1a03f78 commit 5232255
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 15 deletions.
11 changes: 5 additions & 6 deletions .github/actions/release/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ inputs:
tag-name:
description: 'The name of the tag for the GitHub release'
required: true
github-token:
description: 'GitHub token'
required: true

runs:
using: "composite"
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
Expand All @@ -31,8 +29,9 @@ runs:
uses: softprops/action-gh-release@v1
with:
files: dist/*
tag_name: "${{ env.TAG_NAME }}"
tag_name: "${{ inputs.tag-name }}"
body_path: release-notes.md
token: ${{ inputs.github-token }}

- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
permissions:
id-token: write
pull-requests: read
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -71,3 +72,7 @@ jobs:
- name: Create a GitHub release
if: ${{ env.PACKAGE == 'true' }}
uses: ./.github/actions/release
with:
tag-name: ${{ env.TAG_NAME }}
github-token: ${{ secrets.PAT }}
pypi-api-token: ${{ secrets.PYPI_API_TOKEN }}
47 changes: 38 additions & 9 deletions tools/bump.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
#!/usr/bin/env bash

rm -Rf dist
RELEASE_KIND=$(generate-changelog --output release-hint)
echo "::notice::Suggested release type is: ${RELEASE_KIND}"
PR_NUMBER=$(gh pr view --json number -q .number || echo "")
echo "::notice::PR number is: ${PR_NUMBER}"
export PR_NUMBER
bump-my-version bump -v $RELEASE_KIND
python -m build
python -m twine upload dist/*

function extract_version_content() {
changelog=$1
target_version=$2

awk -v target="$target_version" '
/^## / {
if (found) exit;
version=$2;
if (version == target) found=1;
next;
}
found { print; }
' <<< "$changelog"
}

#rm -Rf dist
#RELEASE_KIND=$(generate-changelog --output release-hint)
#echo "::notice::Suggested release type is: ${RELEASE_KIND}"
#PR_NUMBER=$(gh pr view --json number -q .number || echo "")
#echo "::notice::PR number is: ${PR_NUMBER}"
#export PR_NUMBER
#bump-my-version bump -v $RELEASE_KIND
#python -m build
#python -m twine upload dist/*

changelog=$(cat "CHANGELOG.md")
TARGET_VERSION=$(bump-my-version show current_version)
echo "TAG_NAME=$TARGET_VERSION"
NOTES=$(extract_version_content "$changelog" "$TARGET_VERSION")


gh release create \
"${TARGET_VERSION}" \
./dist/* \
--title "${TARGET_VERSION}" \
--notes "${NOTES}" \
--draft \
28 changes: 28 additions & 0 deletions tools/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash


function extract_version_content() {
changelog=$1
target_version=$2

awk -v target="$target_version" '
/^## / {
if (found) exit;
version=$2;
if (version == target) found=1;
next;
}
found { print; }
' <<< "$changelog"
}

changelog=$(cat "CHANGELOG.md")
TARGET_VERSION=$(bump-my-version show current_version)
NOTES=$(extract_version_content "$changelog" "$TARGET_VERSION")
echo "Creating a GitHub release for version ${TARGET_VERSION} with notes."
gh release create \
"${TARGET_VERSION}" \
./dist/* \
--title "${TARGET_VERSION}" \
--notes "${NOTES}" \
--draft

0 comments on commit 5232255

Please sign in to comment.