From 22d61d8f95c85d4b63b39e3a026f07a528fe7bf4 Mon Sep 17 00:00:00 2001 From: otegami Date: Fri, 13 Dec 2024 12:05:59 +0900 Subject: [PATCH] ci deploy: release add deploy workflow to notify successful package upload GitHub: https://github.com/groonga/packages.groonga.org/issues/43 This PR introduces a new release workflow. This release workflow handdle the followings. We will implement it step by step. - Create release page <- This PR is here. - Upload the release artifacts to release page --- .github/workflows/document.yml | 9 ++++ .github/workflows/package.yml | 10 +++++ .github/workflows/release.yml | 80 +++++++++++++++++++--------------- 3 files changed, 65 insertions(+), 34 deletions(-) diff --git a/.github/workflows/document.yml b/.github/workflows/document.yml index 5c71db51b4..14b16c8c71 100644 --- a/.github/workflows/document.yml +++ b/.github/workflows/document.yml @@ -66,6 +66,15 @@ jobs: run: gh release upload ${{ github.ref_name }} document-*.tar.gz env: GH_TOKEN: ${{ github.token }} + release: + if: | + github.ref_type == 'tag' + needs: build + uses: ./.github/workflows/release.yml + with: + tag: ${{ github.ref_name }} + secrets: + token: ${{ secrets.GITHUB_TOKEN }} # todo: Documents generated by Doxygen are also built with CMake. doxygen: name: Doxygen diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index bec5ae327c..d4b4972c8a 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -309,3 +309,13 @@ jobs: --volume ${PWD}:/groonga:ro \ ${TEST_DOCKER_IMAGE} \ /groonga/packages/${TASK_NAMESPACE}/test.sh + + release: + if: | + github.ref_type == 'tag' + needs: build + uses: ./.github/workflows/release.yml + with: + tag: ${{ github.ref_name }} + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 81ef0fe476..5fdb9f7d04 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,43 +1,55 @@ name: Release on: - push: - tags: - - '*' + workflow_call: + inputs: + tag: + required: true + type: string + secrets: + token: + required: true jobs: page: steps: - uses: actions/checkout@v4 - name: Create release page run: | - (cd doc/source/news && \ - ruby \ - -e 'print("## Groonga "); \ - puts(ARGF.read.split(/^## Release /)[1]. \ - gsub(/^\(.+\)=$/, ""). \ - gsub(/{doc}`(.+?)`/) { \ - id = $1; \ - title = id.split("\/").last; \ - path = id.delete_prefix("/"); \ - url = "https://groonga.org/docs/#{path}.html"; \ - "[#{title}](#{url})"; \ - }. \ - gsub(/{ref}`(.+?)`/) {$1}. - strip)' \ - $(ls *.md | sort --human-numeric-sort | tail -n1)) > \ - release-note.md - echo "" >> release-note.md - echo "### Translations" >> release-note.md - echo "" >> release-note.md - version=${GITHUB_REF_NAME#v} - major_version=${version%%.*} - version_hyphen=$(echo ${version} | tr . -) - echo " * [Japanese](https://groonga.org/ja/docs/news/${major_version}.html#release-${version_hyphen})" >> release-note.md - title="$(head -n1 release-note.md | sed -e 's/^## //')" - tail -n +2 release-note.md > release-note-without-version.md - gh release create ${GITHUB_REF_NAME} \ - --discussion-category Releases \ - --notes-file release-note-without-version.md \ - --title "${title}" + if gh release view "${{ inputs.tag }}" > /dev/null 2>&1; then + echo "Skip the creation step for Release ${{ inputs.tag }}." + else + gh release create "${{ inputs.tag }}" \ + --title "release-${{ inputs.tag }}" + (cd doc/source/news && \ + ruby \ + -e 'print("## Groonga "); \ + puts(ARGF.read.split(/^## Release /)[1]. \ + gsub(/^\(.+\)=$/, ""). \ + gsub(/{doc}`(.+?)`/) { \ + id = $1; \ + title = id.split("\/").last; \ + path = id.delete_prefix("/"); \ + url = "https://groonga.org/docs/#{path}.html"; \ + "[#{title}](#{url})"; \ + }. \ + gsub(/{ref}`(.+?)`/) {$1}. + strip)' \ + $(ls *.md | sort --human-numeric-sort | tail -n1)) > \ + release-note.md + echo "" >> release-note.md + echo "### Translations" >> release-note.md + echo "" >> release-note.md + tag=${{ inputs.tag }} + version=${tag#v} + major_version=${version%%.*}inputs.tag + version_hyphen=$(echo ${version} | tr . -) + echo " * [Japanese](https://groonga.org/ja/docs/news/${major_version}.html#release-${version_hyphen})" >> release-note.md + title="$(head -n1 release-note.md | sed -e 's/^## //')" + tail -n +2 release-note.md > release-note-without-version.md + gh release create ${{ inputs.tag }} \ + z--discussion-category Releases \ + --notes-file release-note-without-version.md \ + --title "${title}" + fi env: - GH_TOKEN: ${{ github.token }} - + GH_TOKEN: ${{ secrets.token }} + # todo: donwload uploaded artifacts from caller workflow and upload them to release page.