graph complete and bugs fixed. (#1) #12
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: Auto Tag on Merge | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| tag: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Read version from pyproject.toml | |
| id: version | |
| run: | | |
| VERSION=$(python3 -c " | |
| import tomllib | |
| with open('pyproject.toml', 'rb') as f: | |
| data = tomllib.load(f) | |
| print(data['project']['version']) | |
| ") | |
| echo "version=v$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Check if tag already exists | |
| id: check_tag | |
| run: | | |
| if git rev-parse "${{ steps.version.outputs.version }}" > /dev/null 2>&1; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create and push tag | |
| if: steps.check_tag.outputs.exists == 'false' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag "${{ steps.version.outputs.version }}" | |
| git push origin "${{ steps.version.outputs.version }}" | |
| - name: Extract changelog for this version | |
| if: steps.check_tag.outputs.exists == 'false' | |
| id: changelog | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| NOTES=$(python3 -c " | |
| import re, sys | |
| version = sys.argv[1].lstrip('v') | |
| with open('CHANGELOG.md') as f: | |
| content = f.read() | |
| pattern = rf'## \[{re.escape(version)}\].*?\n(.*?)(?=\n## \[|\Z)' | |
| match = re.search(pattern, content, re.DOTALL) | |
| print(match.group(1).strip() if match else '') | |
| " "$VERSION") | |
| echo "$NOTES" > /tmp/release_notes.md | |
| - name: Create GitHub Release | |
| if: steps.check_tag.outputs.exists == 'false' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "${{ steps.version.outputs.version }}" \ | |
| --title "${{ steps.version.outputs.version }}" \ | |
| --notes-file /tmp/release_notes.md |