Create Release #2
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: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g. v1.1.0)' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: main | |
| - name: Parse version | |
| id: version | |
| run: | | |
| VERSION="${{ inputs.version }}" | |
| if [[ "$VERSION" != v* ]]; then | |
| VERSION="v${VERSION}" | |
| fi | |
| echo "tag=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Parse changelog for release notes | |
| run: | | |
| TAG="${{ steps.version.outputs.tag }}" | |
| SECTION=$(awk -v ver="$TAG" ' | |
| BEGIN { found=0 } | |
| /^## \[v/ { | |
| if (found) exit | |
| if (index($0, ver)) found=1 | |
| next | |
| } | |
| found { print } | |
| ' CHANGELOG.md) | |
| if [ -z "$SECTION" ]; then | |
| echo "::error::No changelog entry found for version ${TAG}" | |
| exit 1 | |
| fi | |
| BREAKING=$(echo "$SECTION" | awk ' | |
| BEGIN { found=0 } | |
| /^### !!! Breaking Changes/ { found=1; next } | |
| /^###/ { if (found) exit } | |
| found && /^- / { print } | |
| ') | |
| ADDED=$(echo "$SECTION" | awk ' | |
| BEGIN { found=0 } | |
| /^### Added/ { found=1; next } | |
| /^###/ { if (found) exit } | |
| found && /^- / && !/N\/A/ { print } | |
| ') | |
| CHANGED=$(echo "$SECTION" | awk ' | |
| BEGIN { found=0 } | |
| /^### Changed/ { found=1; next } | |
| /^###/ { if (found) exit } | |
| found && /^- / && !/N\/A/ { print } | |
| ') | |
| FIXED=$(echo "$SECTION" | awk ' | |
| BEGIN { found=0 } | |
| /^### Fixed/ { found=1; next } | |
| /^###/ { if (found) exit } | |
| found && /^- / && !/N\/A/ { print } | |
| ') | |
| NOTES="" | |
| if [ -n "$BREAKING" ]; then | |
| NOTES="### Breaking Changes | |
| ${BREAKING} | |
| " | |
| fi | |
| if [ -n "$ADDED" ]; then | |
| NOTES="${NOTES}### Added | |
| ${ADDED} | |
| " | |
| fi | |
| if [ -n "$CHANGED" ]; then | |
| NOTES="${NOTES}### Changed | |
| ${CHANGED} | |
| " | |
| fi | |
| if [ -n "$FIXED" ]; then | |
| NOTES="${NOTES}### Fixed | |
| ${FIXED} | |
| " | |
| fi | |
| NOTES="${NOTES}[Full changelog](https://github.com/anaconda/anaconda-otel-python/blob/main/CHANGELOG.md)" | |
| echo "$NOTES" > /tmp/release_notes.md | |
| - name: Create GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh release create "${{ steps.version.outputs.tag }}" \ | |
| --title "${{ steps.version.outputs.tag }}" \ | |
| --target main \ | |
| --notes-file /tmp/release_notes.md |