From d76bbb2bf0de4d6c20e71c7699e8a2edca332fd4 Mon Sep 17 00:00:00 2001 From: Reece Williams <31943163+Reecepbcups@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:33:14 -0500 Subject: [PATCH] simapp(CI): release binary on tag (#109) * goreleaser for binary on tag * docker release comment * final CI comments * spelling * single char, we are done bois --- simapp/.github/workflows/docker-release.yml | 4 + simapp/.github/workflows/release-binary.yml | 43 ++++++++ simapp/.gitignore | 4 +- simapp/.goreleaser.yaml | 114 ++++++++++++++++++++ spawn/file_content.go | 6 +- 5 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 simapp/.github/workflows/release-binary.yml create mode 100644 simapp/.goreleaser.yaml diff --git a/simapp/.github/workflows/docker-release.yml b/simapp/.github/workflows/docker-release.yml index c90ab8e6..88ecc629 100644 --- a/simapp/.github/workflows/docker-release.yml +++ b/simapp/.github/workflows/docker-release.yml @@ -1,5 +1,9 @@ name: docker image release +# NOTE: For this action to work, you must enable write permissions in your github repository settings. +# Settings -> Actions -> General. "Workflow Permissions". Select "Read and write permissions". +# If you forget to enable, the action will fail on push with a 401 error. Just re-run the failed action after enabling. + on: push: tags: diff --git a/simapp/.github/workflows/release-binary.yml b/simapp/.github/workflows/release-binary.yml new file mode 100644 index 00000000..59b30956 --- /dev/null +++ b/simapp/.github/workflows/release-binary.yml @@ -0,0 +1,43 @@ +name: "Release Binary" + +# Pairs with .goreleaser.yaml file for configuration. + +on: + push: + tags: + - '**' + +# Test Locally with: +# goreleaser build --skip-validate --snapshot --clean + +jobs: + goreleaser: + permissions: write-all + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v2 + with: + go-version: '1.21' + + - name: Clean up dist directory + run: rm -rf dist + + - name: Build + uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: build --skip-validate + + - name: Release + uses: goreleaser/goreleaser-action@v5 + if: startsWith(github.ref, 'refs/tags/') + with: + version: latest + args: release --skip-validate --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/simapp/.gitignore b/simapp/.gitignore index 7e63cc36..b9c0fc37 100644 --- a/simapp/.gitignore +++ b/simapp/.gitignore @@ -1 +1,3 @@ -configs/logs.json \ No newline at end of file +configs/logs.json + +dist/ \ No newline at end of file diff --git a/simapp/.goreleaser.yaml b/simapp/.goreleaser.yaml new file mode 100644 index 00000000..4d4e5eb0 --- /dev/null +++ b/simapp/.goreleaser.yaml @@ -0,0 +1,114 @@ +project_name: simapp + +release: + github: + owner: rollchains + name: simapp + name_template: '{{.Tag}}' + +# Only uncomment os, arch, and targets if you are NOT using cosmwasm / wasm-light-client. +# Windows, 386 (32bit), and ARM are not Wasm compatible. +builds: + - id: simapp + goos: + - linux + - darwin + # - windows + goarch: + - amd64 + # - arm64 + # - "386" + goarm: + - "6" + gomips: + - hardfloat + goamd64: + - v1 + targets: + - linux_amd64_v1 + # - darwin_amd64_v1 + # - linux_arm64 + # - linux_386 + # - darwin_arm64 + # - windows_amd64_v1 + # - windows_arm64 + # - windows_386 + dir: . + main: ./cmd/wasmd + binary: wasmd + builder: go + gobinary: go + command: build + ldflags: + - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser +archives: + - id: default + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' + format: tar.gz + files: + - src: license* + - src: LICENSE* + - src: readme* + - src: README* + - src: changelog* + - src: CHANGELOG* +snapshot: + name_template: '{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}' +checksum: + name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt' + algorithm: sha256 +dist: dist +env_files: + github_token: ~/.config/goreleaser/github_token + gitlab_token: ~/.config/goreleaser/gitlab_token + gitea_token: ~/.config/goreleaser/gitea_token +source: + name_template: '{{ .ProjectName }}-{{ .Version }}' + format: tar.gz +gomod: + gobinary: go +announce: + twitter: + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' + mastodon: + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' + server: "" + reddit: + title_template: '{{ .ProjectName }} {{ .Tag }} is out!' + url_template: '{{ .ReleaseURL }}' + slack: + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' + username: GoReleaser + discord: + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' + author: GoReleaser + color: "3888754" + icon_url: https://goreleaser.com/static/avatar.png + teams: + title_template: '{{ .ProjectName }} {{ .Tag }} is out!' + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' + color: '#2D313E' + icon_url: https://goreleaser.com/static/avatar.png + smtp: + subject_template: '{{ .ProjectName }} {{ .Tag }} is out!' + body_template: 'You can view details from: {{ .ReleaseURL }}' + mattermost: + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' + title_template: '{{ .ProjectName }} {{ .Tag }} is out!' + username: GoReleaser + linkedin: + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' + telegram: + message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' + webhook: + message_template: '{ "message": "{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}"}' + content_type: application/json; charset=utf-8 + opencollective: + title_template: '{{ .Tag }}' + message_template: '{{ .ProjectName }} {{ .Tag }} is out!
Check it out at {{ .ReleaseURL }}' +git: + tag_sort: -version:refname +github_urls: + download: https://github.com +gitlab_urls: + download: https://gitlab.com diff --git a/spawn/file_content.go b/spawn/file_content.go index 2e402675..be17ff74 100644 --- a/spawn/file_content.go +++ b/spawn/file_content.go @@ -102,7 +102,11 @@ func (fc *FileContent) ReplaceGithubActionWorkflows(cfg *NewChainConfig) { if fc.IsPath(path.Join(".github", "workflows", "docker-release.yml")) { fc.ReplaceAll("/go/bin/wasmd", fmt.Sprintf("/go/bin/%s", cfg.BinDaemon)) } - + if fc.ContainsPath(".goreleaser.yaml") { + fc.ReplaceAll("rollchains", cfg.GithubOrg) + fc.ReplaceAll("simapp", cfg.ProjectName) + fc.ReplaceAll("wasmd", cfg.BinDaemon) + } } func (fc *FileContent) ReplaceDockerFile(cfg *NewChainConfig) {