Merge pull request #74 from NorthShoreAutomation/bugfix/bad-response-… #44
Workflow file for this run
This file contains hidden or 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
| name: Create Release | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| workflow_call: | |
| inputs: | |
| publish_test: | |
| description: "Whether to publish to test PyPI instead of main PyPI" | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version from tag | |
| id: get_version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Extract release name from changelog | |
| id: get_release_name | |
| run: | | |
| VERSION=${{ steps.get_version.outputs.VERSION }} | |
| echo "Looking for version: ${VERSION}" | |
| # First find the line containing our version (using awk for more precise matching) | |
| VERSION_LINE=$(awk -v ver="$VERSION" '/version.*{ver}/ { print; exit }' docs/CHANGELOG.md) | |
| if [ -z "$VERSION_LINE" ]; then | |
| echo "Could not find version line for ${VERSION}" | |
| VERSION_LINE=$(head -n 5 docs/CHANGELOG.md | grep "version") | |
| echo "Using first version line instead: ${VERSION_LINE}" | |
| fi | |
| echo "Found version line: ${VERSION_LINE}" | |
| # Then extract the text between quotes | |
| RELEASE_NAME=$(echo "$VERSION_LINE" | grep -o '"[^"]*"' | tr -d '"') | |
| if [ -z "$RELEASE_NAME" ]; then | |
| echo "Could not extract release name, using default" | |
| RELEASE_NAME="Release" | |
| fi | |
| echo "Extracted release name: ${RELEASE_NAME}" | |
| # Set the output (using the new GITHUB_OUTPUT syntax) | |
| { | |
| echo "RELEASE_NAME<<EOF" | |
| echo "${RELEASE_NAME}" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Generate Release Notes | |
| id: release_notes | |
| run: | | |
| PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| if [ -z "$PREVIOUS_TAG" ]; then | |
| CHANGES=$(git log --pretty=format:"- %s" ${{ steps.get_version.outputs.VERSION }}) | |
| else | |
| CHANGES=$(git log --pretty=format:"- %s" ${PREVIOUS_TAG}..${{ steps.get_version.outputs.VERSION }}) | |
| fi | |
| { | |
| echo "CHANGES<<EOF" | |
| echo "$CHANGES" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Debug Outputs | |
| run: | | |
| echo "Version: ${{ steps.get_version.outputs.VERSION }}" | |
| echo "Release Name: ${{ steps.get_release_name.outputs.RELEASE_NAME }}" | |
| echo "Changes: ${{ steps.release_notes.outputs.CHANGES }}" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: "${{ steps.get_version.outputs.VERSION }} - ${{ steps.get_release_name.outputs.RELEASE_NAME }}" | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| make_latest: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish: | |
| needs: release | |
| uses: ./.github/workflows/publish.yml | |
| with: | |
| publish_test: ${{ inputs.publish_test == 'true' }} | |
| secrets: inherit |