Merge pull request #641 from gdsfactory/chore/bump-doroutes-1.1.0 #335
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| check_and_tag: | |
| name: Check for version bump and create tag | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.get_version.outputs.tag }} | |
| new_tag_created: ${{ steps.check_tag.outputs.new_tag }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Get version | |
| id: get_version | |
| run: | | |
| VERSION=$(grep -m 1 '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Check if tag exists and create if not | |
| id: check_tag | |
| run: | | |
| TAG=${{ steps.get_version.outputs.tag }} | |
| if git ls-remote --exit-code --tags origin "refs/tags/$TAG"; then | |
| echo "Tag $TAG already exists. No new release will be created." | |
| echo "new_tag=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Tag $TAG does not exist. Creating and pushing tag." | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$TAG" -m "Release ${{ steps.get_version.outputs.version }}" | |
| git push origin "$TAG" | |
| echo "new_tag=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| build: | |
| needs: check_and_tag | |
| if: needs.check_and_tag.outputs.new_tag_created == 'true' | |
| permissions: | |
| contents: read | |
| uses: ./.github/workflows/build.yml | |
| release_environment: | |
| needs: check_and_tag | |
| if: needs.check_and_tag.outputs.new_tag_created == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 | |
| - name: Generate SBOM | |
| run: | | |
| uv run --all-extras --with cyclonedx-bom cyclonedx-py environment --pyproject pyproject.toml --output-format JSON --output-file sbom.json | |
| - name: Create Release | |
| run: | | |
| # Get the latest draft release tag if it exists | |
| DRAFT_TAG=$(gh release list --limit 1 --json isDraft,tagName --jq '.[] | select(.isDraft==true) | .tagName' || echo "") | |
| if [ -n "$DRAFT_TAG" ]; then | |
| # Get the body of the draft release | |
| DRAFT_BODY=$(gh release view "$DRAFT_TAG" --json body --jq '.body' || echo "") | |
| # Create release with draft body | |
| gh release create ${{ needs.check_and_tag.outputs.tag }} \ | |
| --title "${{ needs.check_and_tag.outputs.tag }}" \ | |
| --notes "$DRAFT_BODY" \ | |
| sbom.json | |
| else | |
| # Create release with auto-generated notes | |
| gh release create ${{ needs.check_and_tag.outputs.tag }} \ | |
| --title "${{ needs.check_and_tag.outputs.tag }}" \ | |
| --generate-notes \ | |
| sbom.json | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| release_pypi: | |
| needs: [check_and_tag, build] | |
| if: needs.check_and_tag.outputs.new_tag_created == 'true' | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/qpdk | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | |
| with: | |
| name: dist | |
| path: dist | |
| - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1 | |
| with: | |
| packages-dir: dist |