Merge pull request #21 from StructuralGenomicsConsortium/nabin-working #19
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 | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| concurrency: | |
| group: "release-${{ github.ref }}" | |
| cancel-in-progress: false | |
| defaults: | |
| run: | |
| shell: bash -l {0} | |
| jobs: | |
| test: | |
| uses: ./.github/workflows/test.yaml | |
| check-semver: | |
| if: github.ref_name == github.event.repository.default_branch | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| outputs: | |
| release-version: ${{ steps.bump_version.outputs.release_version }} | |
| steps: | |
| - name: Checkout the code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get latest tag | |
| id: get_tag | |
| run: | | |
| tag=$(git describe --tags --abbrev=0 || echo "v0.0.0") | |
| echo "Latest tag: $tag" | |
| echo "tag=$tag" >> $GITHUB_OUTPUT | |
| - name: Calculate next version | |
| id: bump_version | |
| run: | | |
| latest=${{ steps.get_tag.outputs.tag }} | |
| # Strip the 'v' prefix | |
| latest=${latest#v} | |
| IFS='.' read -r major minor patch <<< "$latest" | |
| patch=$((patch + 1)) | |
| next_version="v$major.$minor.$patch" | |
| echo "Next version will be: $next_version" | |
| echo "release_version=$next_version" >> $GITHUB_OUTPUT | |
| release: | |
| needs: [test, check-semver] | |
| if: needs.check-semver.result == 'success' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RELEASE_VERSION: ${{ needs.check-semver.outputs.release-version }} | |
| steps: | |
| - name: Checkout the code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Install the project | |
| run: uv sync --frozen --all-groups --python 3.12 | |
| - name: Build Changelog | |
| id: github_release | |
| uses: mikepenz/release-changelog-builder-action@v5 | |
| with: | |
| toTag: ${{ env.RELEASE_VERSION }} | |
| configuration: ".github/changelog_config.json" | |
| - name: Create and push git tag | |
| run: | | |
| git config --global user.name "${GITHUB_ACTOR}" | |
| git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
| git tag -a "${RELEASE_VERSION}" -m "Release version ${RELEASE_VERSION}" | |
| git push origin "${RELEASE_VERSION}" | |
| - name: Build the wheel and sdist | |
| run: uv build | |
| - name: Publish package to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| packages-dir: dist/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ env.RELEASE_VERSION }} | |
| body: ${{ steps.github_release.outputs.changelog }} |