Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add build-release workflow and decouple Goreleaser #1311

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +29 to +46
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Update GitHub Actions to their latest versions

Several actions are using outdated versions which may have security fixes or improvements in newer versions.

Apply these version updates:

- uses: actions/checkout@v3
+ uses: actions/checkout@v4

- uses: actions/setup-go@v4
+ uses: actions/setup-go@v5

- uses: goreleaser/goreleaser-action@v4
+ uses: goreleaser/goreleaser-action@v5
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- 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
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
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
🧰 Tools
🪛 actionlint (1.7.4)

30-30: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


34-34: the runner of "actions/setup-go@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


38-38: the runner of "goreleaser/goreleaser-action@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

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
Comment on lines +47 to +49
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix shell script quoting issues

The artifact renaming step has potential issues with word splitting and globbing.

Apply this fix:

- run: for f in $ARTIFACTS; do mv $f $(echo $f | sed -E 's/_0\.0\.0-SNAPSHOT-[^_]*/_${{ inputs.name }}/'); done
+ run: for f in "$ARTIFACTS"; do mv "$f" "$(echo "$f" | sed -E 's/_0\.0\.0-SNAPSHOT-[^_]*/_${{ inputs.name }}/')"; done
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
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
🧰 Tools
🪛 actionlint (1.7.4)

48-48: shellcheck reported issue in this script: SC2086:info:1:28: Double quote to prevent globbing and word splitting

(shellcheck)


48-48: shellcheck reported issue in this script: SC2046:warning:1:31: Quote this to prevent word splitting

(shellcheck)


48-48: shellcheck reported issue in this script: SC2086:info:1:38: Double quote to prevent globbing and word splitting

(shellcheck)

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
Comment on lines +63 to +68
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Update action-download-artifact to latest version

The action for downloading artifacts is using an outdated version.

Apply this version update:

- uses: dawidd6/action-download-artifact@v2
+ uses: dawidd6/action-download-artifact@v3
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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: dawidd6/action-download-artifact@v3
with:
workflow: release.yml
name: changelog-${{ inputs.new_tag }}
- name: Create GitHub release
🧰 Tools
🪛 actionlint (1.7.4)

64-64: the runner of "dawidd6/action-download-artifact@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

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
57 changes: 0 additions & 57 deletions .github/workflows/build_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ jobs:
sha: ${{ github.sha }}
secrets: inherit

build-release:
needs: [ci-server, build-prepare]
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
Expand Down
Loading