Skip to content

Commit

Permalink
Add go releaser (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
2xburnt committed Oct 2, 2024
1 parent 3cebc42 commit 28c2203
Show file tree
Hide file tree
Showing 25 changed files with 1,041 additions and 614 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Folders we don't want to copy to Docker daemon in `docker build . -t cosmwasm/xiond:latest`
.github/
.vscode/
build/
devent/
devnet/
74 changes: 74 additions & 0 deletions .github/workflows/build-release-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build Release Info
# Run for new release tags only

on:
workflow_call:
workflow_dispatch:

jobs:
build-release-info:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}

steps:
- name: checkout
uses: actions/checkout@v4

- name: Prepare environment
run: mkdir -p release

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release
pattern: xiond-*
merge-multiple: true

- name: Create binaries.json
working-directory: release
id: binaries-json
run: |
set -Eeuo pipefail
ls xiond-* | grep -v 'xiond-darwin-all' | while read -r file; do
platform=$(echo $file | cut -d- -f2- | sed -E 's/^rc[0-9]*-//g; s/-/\//g')
checksum=$(sha256sum "$file" | awk '{ print $1 }')
echo "$platform: https://github.com/burnt-labs/xion/releases/download/${{ github.ref_name }}/$file?checksum=sha256:$checksum"
done | yq '{"binaries": .}' -o json | tee binaries.json
- name: Upload binaries.json file
uses: actions/upload-artifact@v4
with:
name: binaries.json
path: release/binaries.json
retention-days: 3
if-no-files-found: error

- name: Create version.json
working-directory: release
run: |
set -Eeuo pipefail
upgrade_name=$(echo $GITHUB_REF_NAME | cut -d. -f1)
jq -s '.[0] * (.[1] // {})' <(go mod edit -json | jq --arg name $upgrade_name '{
name: $name,
tag: "${{ github.ref_name }}",
height: 0,
proposal: 0,
go_version: .Go,
cosmos_sdk_version: (.Require[] | select(.Path == "github.com/cosmos/cosmos-sdk") | .Version),
cosmwasm_enabled: (.Require[] | select(.Path == "github.com/CosmWasm/wasmd") != null),
cosmwasm_version: (.Require[] | select(.Path == "github.com/CosmWasm/wasmd") | .Version),
ibc_go_version: (.Require[] | select(.Path == "github.com/cosmos/ibc-go/v7") | .Version),
consensus: {
type: "cometbft",
version: (.Require[] | select(.Path == "github.com/cometbft/cometbft") | .Version)
}
}') binaries.json | tee version.json
- name: Upload version.json files
uses: actions/upload-artifact@v4
with:
name: version.json
path: release/version.json
retention-days: 3
if-no-files-found: error
76 changes: 76 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build Release
# Run for new release tags only

on:
workflow_call:
workflow_dispatch:

jobs:
build-release:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}

steps:
- name: Create release directory
run: mkdir -p release

- name: Build Changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Output Changelog
run: echo "${{steps.changelog.outputs.changelog}}"

- name: Create release for ${{ github.ref_name }}
id: update-release
uses: ncipollo/release-action@v1
with:
name: Release ${{ github.ref_name }}
allowUpdates: true
body: ${{ steps.changelog.outputs.changelog }}
draft: false
generateReleaseNotes: true
prerelease: true
removeArtifacts: false # important, true will remove src archives
tag: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
updateOnlyUnreleased: true

- name: Download release archives
working-directory: release
run: |
gh release download ${{ github.ref_name }} \
--repo=${{ github.repository }} \
--archive=tar.gz
gh release download ${{ github.ref_name }} \
--repo=${{ github.repository }} \
--archive=zip
ls
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release
pattern: xiond-*
merge-multiple: true

- name: Create checksums
working-directory: release
run: |
sha256sum * | tee checksum.txt
- name: Remove release archives
working-directory: release
run: |
rm -f *.zip *.tar.gz
ls
- name: Upload release assets
working-directory: release
run: |
gh release upload ${{ github.ref_name }} * \
--repo ${{ github.repository }} \
--clobber
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@ concurrency:
jobs:
lint:
name: Golang CI Lint
uses: burnt-labs/xion/.github/workflows/golangci-lint.yml@main
uses: burnt-labs/xion/.github/workflows/golangci-lint.yaml@main
secrets: inherit

update-swagger:
name: Update Swagger
uses: burnt-labs/xion/.github/workflows/update-swagger.yml@main
uses: burnt-labs/xion/.github/workflows/update-swagger.yaml@main
secrets: inherit

unit-tests:
name: Go Unit Tests
uses: burnt-labs/xion/.github/workflows/tests.yml@main
uses: burnt-labs/xion/.github/workflows/tests.yaml@main
secrets: inherit

build-docker:
name: Build Docker Images
uses: burnt-labs/xion/.github/workflows/docker-build.yml@main
uses: burnt-labs/xion/.github/workflows/docker-build.yaml@main
secrets: inherit

docker-scout:
needs: build-docker
name: Docker Scout
uses: burnt-labs/xion/.github/workflows/docker-scout.yml@main
uses: burnt-labs/xion/.github/workflows/docker-scout.yaml@main
secrets: inherit

interchain-tests:
needs: build-docker
name: Interchain tests
uses: burnt-labs/xion/.github/workflows/integration-tests.yml@main
uses: burnt-labs/xion/.github/workflows/integration-tests.yaml@main
secrets: inherit
86 changes: 86 additions & 0 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Create Release
# Run for new release tags only

on:
workflow_dispatch:
push:
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+'
- 'v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Golang CI Lint
uses: burnt-labs/xion/.github/workflows/golangci-lint.yaml@main
secrets: inherit

update-swagger:
name: Update Swagger
uses: burnt-labs/xion/.github/workflows/update-swagger.yaml@main
secrets: inherit

unit-tests:
name: Go Unit Tests
uses: burnt-labs/xion/.github/workflows/tests.yaml@main
secrets: inherit

build-darwin-binaries:
name: Build Darwin Binaries
uses: burnt-labs/xion/.github/workflows/darwin-build.yaml@main
secrets: inherit

build-docker:
name: Build Docker Images
uses: burnt-labs/xion/.github/workflows/docker-build.yaml@main
secrets: inherit

push-docker:
name: Push Docker Images
needs: build-docker
uses: burnt-labs/xion/.github/workflows/docker-push.yaml@main
secrets: inherit

docker-scout:
name: Docker Scout
needs: build-docker
uses: burnt-labs/xion/.github/workflows/docker-scout.yaml@main
secrets: inherit

interchain-tests:
name: Interchain tests
needs: build-docker
uses: burnt-labs/xion/.github/workflows/integration-tests.yaml@main
secrets: inherit

build-release-info:
name: Build Release Info
needs:
- build-docker
- build-darwin-binaries
uses: burnt-labs/xion/.github/workflows/build-release-info.yaml@main
secrets: inherit

build-release:
name: Build Release
needs:
- lint
- update-swagger
- unit-tests
- docker-scout
- interchain-tests
- build-release-info
- build-darwin-binaries
uses: burnt-labs/xion/.github/workflows/build-release.yaml@main
secrets: inherit

update-networks:
name: Update Networks Repo
needs:
- build-release
- build-release-info
uses: burnt-labs/xion/.github/workflows/update-networks.yaml@main
secrets: inherit
57 changes: 57 additions & 0 deletions .github/workflows/darwin-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build Darwin Binaries

# reusable workflow, do not add triggers
on:
workflow_call:
workflow_dispatch:

jobs:
build-darwin-images:
name: Build Darwin Binaries
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set Go Version
run: sed -En 's/^go (.*)$/GO_VERSION=\1/p' go.mod >> $GITHUB_ENV

- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Build darwin all
run: |
make build-darwin-all
- name: Rename darwin binaries
run: |
for file in dist/xiond_darwin_*/xiond; do
cp $file ${{ runner.temp }}/$(basename $(dirname $file) | sed 's/_/-/g')
done
- name: Upload arm64 binary
uses: actions/upload-artifact@v4
with:
name: xiond-darwin-arm64
path: ${{ runner.temp }}/xiond-darwin-arm64
retention-days: 3
if-no-files-found: error

- name: Upload amd64 binary
uses: actions/upload-artifact@v4
with:
name: xiond-darwin-amd64
path: ${{ runner.temp }}/xiond-darwin-amd64
retention-days: 3
if-no-files-found: error

- name: Upload all binary
uses: actions/upload-artifact@v4
with:
name: xiond-darwin-all
path: ${{ runner.temp }}/xiond-darwin-all
retention-days: 3
if-no-files-found: error
Loading

0 comments on commit 28c2203

Please sign in to comment.