diff --git a/.github/workflows/_build-wheel-release-upload.yml b/.github/workflows/_build-wheel-release-upload.yml index 43c0373..83625d0 100644 --- a/.github/workflows/_build-wheel-release-upload.yml +++ b/.github/workflows/_build-wheel-release-upload.yml @@ -75,6 +75,38 @@ jobs: commit_message: update changelog branch: main + delete-create-new-tag: + # For a full release, we delete and create a new tag to reflect the latest changes in the CHANGELOG.rst. + # Recall that during the full release, the `main` branch's CHANGELOG.rst has been updated, and we want the + # tag to reflect the latest changes in the CHANGELOG.rst done by the update-changelog above. + # For more discussions, please read https://github.com/Billingegroup/release-scripts/pull/120 + needs: [update-changelog] + # Always run this job for a full release but fail if the update-changelog job previously failed. + if: "always() && !contains(github.ref, 'rc')" + runs-on: ubuntu-latest + steps: + - name: Fail delete-create-new-tag job if CHANGELOG update failed + run: | + if [ "${{ needs.update-changelog.result }}" == 'success' ]; then + echo "Ready to delete and create new tag containing the latest CHANGELOG.rst update in the main branch..." + else + echo "Previous update-changelog job failed; exiting..." + exit 1 + fi + - name: Checkout the repository + uses: actions/checkout@v4 + with: + ref: main + - name: Delete the tag + run: | + git fetch --tags + git tag -d "${{ github.ref_name }}" + git push origin ":${{ github.ref_name }}" + - name: Create a new tag (Expect commit SHA to match with that of main branch) + run: | + git tag "${{ github.ref_name }}" + git push origin "${{ github.ref_name }}" + github-pre-release: needs: [build-pure-python-package, build-non-pure-python-package] if: "always() && contains(github.ref, 'rc')" @@ -97,13 +129,13 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} github-release: - needs: [update-changelog] + needs: [delete-create-new-tag] if: "always() && !contains(github.ref, 'rc')" runs-on: ubuntu-latest steps: - name: Fail github-release job if CHANGELOG update failed run: | - if [ "${{ needs.update-changelog.result }}" == 'success' ]; then + if [ "${{ needs.delete-create-new-tag.result }}" == 'success' ]; then echo "Ready to release on GitHub..." else echo "Previous update-changelog job failed; exiting..." @@ -159,3 +191,11 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | twine upload dist/* --verbose + + docs: + needs: [github-pre-release, github-release] + if: always() + uses: ./.github/workflows/_publish-docs-on-release.yml + with: + project: ${{ inputs.project }} + c_extension: ${{ inputs.c_extension }} diff --git a/.github/workflows/_publish-docs-on-release.yml b/.github/workflows/_publish-docs-on-release.yml index e86300a..b77bcbb 100644 --- a/.github/workflows/_publish-docs-on-release.yml +++ b/.github/workflows/_publish-docs-on-release.yml @@ -25,7 +25,7 @@ on: type: boolean jobs: - docs: + build-deploy: defaults: run: shell: bash -l {0} @@ -35,7 +35,7 @@ jobs: - name: Check out ${{ inputs.project }} uses: actions/checkout@v4 with: - fetch-depth: 0 # Fetches branches and tags + ref: ${{ github.ref }} - name: Initialize miniconda uses: conda-incubator/setup-miniconda@v3