From 9122b2eb64dc29c8721610ef41fc3c905ac876ad Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Thu, 12 Dec 2024 13:19:20 +0100 Subject: [PATCH 1/2] ci: add release workflow Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- .github/workflows/build_release.yml | 77 +++++++++++++++++++++++++++++ .github/workflows/build_server.yml | 57 --------------------- .github/workflows/ci.yml | 11 +++++ 3 files changed, 88 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/build_release.yml diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml new file mode 100644 index 000000000..2a187a43e --- /dev/null +++ b/.github/workflows/build_release.yml @@ -0,0 +1,77 @@ +name: build-release +on: + workflow_call: + inputs: + sha_short: + type: string + required: true + new_tag: + type: string + required: true + new_tag_short: + type: string + required: true + name: + type: string + required: true + sha: + type: string + required: true + +jobs: + server: + name: Build and release server + runs-on: ubuntu-latest + if: inputs.name || inputs.new_tag + env: + ARTIFACTS: server/dist/reearth_*.* + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: ~> v2 + args: release --clean ${{ inputs.new_tag == '' && '--snapshot' || '' }} + workdir: server + env: + GORELEASER_CURRENT_TAG: ${{ inputs.new_tag == '' && '0.0.0' || inputs.new_tag }} + - name: Rename artifacts + if: ${{ inputs.name != '' }} + run: for f in $ARTIFACTS; do mv $f $(echo $f | sed -E 's/_0\.0\.0-SNAPSHOT-[^_]*/_${{ inputs.name }}/'); done + - name: List artifacts + run: ls -l server/dist + - name: Release nightly/rc + if: ${{ inputs.name != '' }} + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + artifacts: ${{ env.ARTIFACTS }} + commit: ${{ inputs.sha }} + name: ${{ inputs.name }} + tag: ${{ inputs.name }} + body: ${{ inputs.sha_short }} + prerelease: true + - name: Download latest changelog + if: ${{ inputs.new_tag != '' }} + uses: dawidd6/action-download-artifact@v2 + with: + workflow: release.yml + name: changelog-${{ inputs.new_tag }} + - name: Create GitHub release + if: ${{ inputs.new_tag != '' }} + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + artifacts: ${{ env.ARTIFACTS }} + commit: ${{ inputs.sha }} + name: ${{ inputs.new_tag }} + tag: ${{ inputs.new_tag}} + bodyFile: CHANGELOG_latest.md diff --git a/.github/workflows/build_server.yml b/.github/workflows/build_server.yml index 470fb9471..6c2c78cb2 100644 --- a/.github/workflows/build_server.yml +++ b/.github/workflows/build_server.yml @@ -19,63 +19,6 @@ on: required: true jobs: - build-server: - name: Build and release server - runs-on: ubuntu-latest - if: inputs.name || inputs.new_tag - env: - ARTIFACTS: server/dist/reearth_*.* - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.21" - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 - with: - distribution: goreleaser - version: ~> v2 - args: release --clean ${{ inputs.new_tag == '' && '--snapshot' || '' }} - workdir: server - env: - GORELEASER_CURRENT_TAG: ${{ inputs.new_tag == '' && '0.0.0' || inputs.new_tag }} - - name: Rename artifacts - if: ${{ inputs.name != '' }} - run: for f in $ARTIFACTS; do mv $f $(echo $f | sed -E 's/_0\.0\.0-SNAPSHOT-[^_]*/_${{ inputs.name }}/'); done - - name: List artifacts - run: ls -l server/dist - - name: Release nightly/rc - if: ${{ inputs.name != '' }} - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - artifacts: ${{ env.ARTIFACTS }} - commit: ${{ inputs.sha }} - name: ${{ inputs.name }} - tag: ${{ inputs.name }} - body: ${{ inputs.sha_short }} - prerelease: true - - name: Download latest changelog - if: ${{ inputs.new_tag != '' }} - uses: dawidd6/action-download-artifact@v2 - with: - workflow: release.yml - name: changelog-${{ inputs.new_tag }} - - name: Create GitHub release - if: ${{ inputs.new_tag != '' }} - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - artifacts: ${{ env.ARTIFACTS }} - commit: ${{ inputs.sha }} - name: ${{ inputs.new_tag }} - tag: ${{ inputs.new_tag}} - bodyFile: CHANGELOG_latest.md - build-docker-image: name: Build and push Docker image runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d66cb7c8c..e19586121 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,17 @@ jobs: sha: ${{ github.sha }} secrets: inherit + build-release: + needs: [build-prepare, build-server] + uses: ./.github/workflows/build_release.yml + with: + sha_short: ${{ needs.build-prepare.outputs.sha_short }} + new_tag: ${{ needs.build-prepare.outputs.new_tag }} + new_tag_short: ${{ needs.build-prepare.outputs.new_tag_short }} + name: ${{ needs.build-prepare.outputs.name }} + sha: ${{ github.sha }} + secrets: inherit + deploy-web: needs: build-web uses: ./.github/workflows/deploy_web_nightly.yml From 622397c595c00e6efe37b8977aaec6e0da8ebf08 Mon Sep 17 00:00:00 2001 From: rot1024 Date: Thu, 12 Dec 2024 22:04:29 +0900 Subject: [PATCH 2/2] Update .github/workflows/ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e19586121..5eb40867d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,7 @@ jobs: secrets: inherit build-release: - needs: [build-prepare, build-server] + needs: [ci-server, build-prepare] uses: ./.github/workflows/build_release.yml with: sha_short: ${{ needs.build-prepare.outputs.sha_short }}