diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9391d246b..ef7502211 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -99,6 +99,19 @@ jobs: with: packages-dir: dist/ + draft-release: + name: Draft a release + needs: [ determine-package, publish ] + runs-on: ubuntu-slim + permissions: + contents: write + steps: + - name: Draft a release. + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ needs.determine-package.outputs.package }}/${{ needs.determine-package.outputs.version }} + run: gh release create ${TAG} --draft --title ${TAG} # Default title is not always the tag name. + docs: name: Build and publish docs needs: [ determine-package, publish ] @@ -112,7 +125,7 @@ jobs: assets: name: Upload docs - needs: [ docs, determine-package ] + needs: [ docs, determine-package, draft-release ] runs-on: ubuntu-24.04 permissions: contents: write @@ -128,14 +141,15 @@ jobs: mv docs_html documentation-${PACKAGE}-${VERSION} zip -r documentation-${PACKAGE}-${VERSION}.zip documentation-${PACKAGE}-${VERSION} - name: Upload release assets - uses: svenstaro/upload-release-action@v2 - with: - file: ./documentation-${{ needs.determine-package.outputs.package }}-${{ needs.determine-package.outputs.version }}.zip - overwrite: false + env: + GH_TOKEN: ${{ github.token }} + ASSET-FILE-PATH: ./documentation-${{ needs.determine-package.outputs.package }}-${{ needs.determine-package.outputs.version }}.zip + TAG: ${{ needs.determine-package.outputs.package }}/${{ needs.determine-package.outputs.version }} + run: gh release upload ${TAG} ${ASSET-FILE-PATH} --clobber # Overwrite existing assets of the same name. notes: name: Update notes - needs: [ determine-package, publish ] + needs: [ determine-package, draft-release ] runs-on: ubuntu-slim if: ${{ always() && needs.determine-package.outputs.lastversion }} permissions: @@ -180,8 +194,8 @@ jobs: run: cat .ess_release_cache/${PACKAGE}-${VERSION}-${PACKAGE}-${LASTVERSION}-releasenote.md >> new-release-note.md - name: Check the generated note run: cat new-release-note.md - - name: Upload release note + - name: Upload release note and publish the release if: ${{ github.event_name != 'workflow_dispatch' }} env: GH_TOKEN: ${{ github.token }} - run: gh release edit ${PACKAGE}/${VERSION} --notes-file "new-release-note.md" + run: gh release edit ${PACKAGE}/${VERSION} --notes-file "new-release-note.md" --draft=false # Publish the release with the new note. diff --git a/tools/collect-release-notes.py b/tools/collect-release-notes.py index 9949bcd87..08f633e2b 100644 --- a/tools/collect-release-notes.py +++ b/tools/collect-release-notes.py @@ -39,7 +39,7 @@ class MergeLog(BaseModel): def __str__(self) -> str: authors = ", ".join([f"@{author.login}" for author in self.authors]) - return f"{self.pr.title} by {authors} in {self.pr.url}" + return f"{self.pr.title} by {authors} in https://github.com/scipp/ess/pull/{self.pr.number}" def get_commits_file(cur_tag: str, compare_tag: str) -> pathlib.Path: @@ -107,12 +107,7 @@ def has_label(label: str, pr: PRDescription) -> bool: else: maybe_relevant_logs.append(merge_log) - release_note = [ - "## What's Changed", - '', - f"### {package_name.replace('ess', 'ESS')}", - '', - ] + release_note = ["## What's Changed"] release_note.extend([f"* {relevant_log}" for relevant_log in relevant_logs]) if args.maybe_relevant: