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 9e3d114
Show file tree
Hide file tree
Showing 12 changed files with 590 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.github/
.vscode/
build/
devent/
devnet/
97 changes: 53 additions & 44 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,77 +6,90 @@ on:
workflow_dispatch:

jobs:
build-docker:
name: main
build-linux-images:
name: Build ${{ matrix.os }}/${{ matrix.arch }}
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || format('burnt-labs-{0}', matrix.arch) }}

strategy:
fail-fast: false
matrix:
os:
- linux
arch:
- amd64
- arm64

permissions:
id-token: write
contents: read
packages: write
strategy:
fail-fast: false
matrix:
runner:
- selector: ubuntu-latest
platform: linux/amd64
- selector: burnt-labs-arm64
platform: linux/arm64
runs-on: ${{ matrix.runner.selector }}

steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
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: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: build --clean --id xiond_${{ matrix.os }}_${{ matrix.arch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up docker buildx for push
uses: docker/setup-buildx-action@v3
with:
driver: docker
platforms: ${{ matrix.runner.platform }}
platforms: ${{ matrix.os }}/${{ matrix.arch }}

- name: Prepare environment
run: |
echo "PLATFORM=${{ matrix.runner.platform }}" | tr '/' '-' | tee -a $GITHUB_ENV
echo "XIOND_FN=xiond/${{ matrix.runner.platform }}" | tr '/' '-' | tee -a $GITHUB_ENV
echo "DOCKER_FN=docker/${{ matrix.runner.platform }}.tar" | tr '/' '-' | tee -a $GITHUB_ENV
echo "HEIGHLINER_FN=heighliner/${{ matrix.runner.platform }}.tar" | tr '/' '-' | tee -a $GITHUB_ENV
echo "VERSION=$(git describe --tags | sed 's/^v//')" | tee -a $GITHUB_ENV
echo "DOCKER_FN=docker-${{ matrix.os }}-${{ matrix.arch }}.tar" | tee -a $GITHUB_ENV
echo "HEIGHLINER_FN=heighliner-${{ matrix.os }}-${{ matrix.arch }}.tar" | tee -a $GITHUB_ENV
- name: Build Docker Image
id: build-docker
uses: docker/build-push-action@v5
with:
build-args: |
COMMIT="${GITHUB_SHA}"
VERSION=${{ env.VERSION }}
TAG_VERSION="${GITHUB_SHA:0:7}"
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.runner.platform }}
push: false
target: release
outputs: type=docker,name=xion:${{ env.PLATFORM }},name-canonical=true
push: false
load: true
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.os }}/${{ matrix.arch }}
tags: xion:${{ matrix.os }}-${{ matrix.arch }}
build-args: |
BINARY=dist/xiond_${{ matrix.os }}_${{ matrix.arch }}/xiond
- name: Build Heighliner Image
id: build-heighliner
uses: docker/build-push-action@v5
with:
build-args: |
BASE_IMAGE=xion
VERSION=${{ env.PLATFORM }}
BINARIES=/usr/bin/xiond
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.runner.platform }}
target: heighliner
outputs: type=docker,name=heighliner:${{ env.PLATFORM }},name-canonical=true
push: false
load: true
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.os }}/${{ matrix.arch }}
tags: heighliner:${{ matrix.os }}-${{ matrix.arch }}
build-args: |
BINARY=dist/xiond_${{ matrix.os }}_${{ matrix.arch }}/xiond
- name: Save Docker Image
working-directory: ${{ runner.temp }}
run: |
docker save xion:${{ env.PLATFORM }} > ${{ env.DOCKER_FN }}
docker save xion:${{ matrix.os }}-${{ matrix.arch }} > ${{ env.DOCKER_FN }}
- name: Upload Docker Image
uses: actions/upload-artifact@v4
Expand All @@ -89,7 +102,7 @@ jobs:
- name: Save Heighliner Image
working-directory: ${{ runner.temp }}
run: |
docker save heighliner:${{ env.PLATFORM }} > ${{ env.HEIGHLINER_FN }}
docker save heighliner:${{ matrix.os }}-${{ matrix.arch }} > ${{ env.HEIGHLINER_FN }}
- name: Upload Heighliner Image
uses: actions/upload-artifact@v4
Expand All @@ -99,19 +112,15 @@ jobs:
if-no-files-found: error
retention-days: 3

- name: Copy xiond binary from container
# if-contains(github.event.ref, 'v[0-9]+\.[0-9]+\.[0-9]+')
working-directory: ${{ runner.temp }}
- name: Rename binary
run: |
tmpname="ctr-$(basename $XIOND_FN)"
docker create --platform ${{ matrix.runner.platform }} --name "${tmpname}" "xion:${PLATFORM}"
docker cp "${tmpname}:/usr/bin/xiond" "${XIOND_FN}"
docker rm -v "${tmpname}"
cp dist/xiond_${{ matrix.os }}_${{ matrix.arch }}/xiond ${{ runner.temp }}/xiond-${{ matrix.os }}-${{ matrix.arch }}
- name: Upload binary
# if-contains(github.event.ref, 'v[0-9]+\.[0-9]+\.[0-9]+')
uses: actions/upload-artifact@v4
with:
name: ${{ env.XIOND_FN }}
path: ${{ runner.temp }}/${{ env.XIOND_FN }}
name: xiond-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ runner.temp }}/xiond-${{ matrix.os }}-${{ matrix.arch }}
if-no-files-found: error
retention-days: 3
13 changes: 8 additions & 5 deletions .github/workflows/docker-scout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [linux/amd64, linux/arm64]
os:
- linux
arch:
- amd64
- arm64

steps:
- name: Login to Docker Hub
Expand All @@ -27,8 +31,7 @@ jobs:

- name: Prepare environment
run: |
echo "PLATFORM=${{ matrix.platform }}" | tr '/' '-' | tee -a $GITHUB_ENV
echo "DOCKER_FN=docker/${{ matrix.platform }}.tar" | tr '/' '-' | tee -a $GITHUB_ENV
echo "DOCKER_FN=docker/${{ matrix.os }}/${{ matrix.arch }}.tar" | tr '/' '-' | tee -a $GITHUB_ENV
- name: Download images
uses: actions/download-artifact@v4
Expand All @@ -48,5 +51,5 @@ jobs:
with:
command: cves
only-fixed: true
platform: ${{ matrix.platform }}
image: xion:${{ env.PLATFORM }}
platform: ${{ matrix.os }}/${{ matrix.arch }}
image: xion:${{ matrix.os }}-${{ matrix.arch }}
72 changes: 37 additions & 35 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ env:

jobs:
build-integration-tests:
runs-on: ${{ matrix.runner.selector }}
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || format('burnt-labs-{0}', matrix.arch) }}
strategy:
fail-fast: false
matrix:
runner:
- selector: ubuntu-latest
platform: linux/amd64
# - selector: burnt-labs-arm64
# platform: linux/arm64
os:
- linux
arch:
- amd64
# - arm64
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Prepare Environment
run: |
sed -En 's/^go (.*)$/GO_VERSION=\1/p' go.mod | tee -a $GITHUB_ENV
echo "PLATFORM=${{ matrix.runner.platform }}" | tr '/' '-' | tee -a $GITHUB_ENV
echo "PLATFORM=${{ matrix.os }}/${{ matrix.arch }}" | tr '/' '-' | tee -a $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
Expand All @@ -44,8 +44,9 @@ jobs:
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: test-${{ env.PLATFORM }}
name: test-${{ matrix.os }}-${{ matrix.arch }}
path: integration_tests/integration_tests.test
if-no-files-found: error
retention-days: 3

- name: find wasmvm lib
Expand All @@ -59,37 +60,38 @@ jobs:
with:
name: ${{ env.WASM_FILE }}
path: ${{ env.WASM_PATH }}
if-no-files-found: error
retention-days: 3

interchain-tests:
runs-on: ${{ matrix.runner.selector }}
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || format('burnt-labs-{0}', matrix.arch) }}
needs: build-integration-tests
strategy:
fail-fast: false
matrix:
runner:
- selector: ubuntu-latest
platform: linux/amd64
# - selector: burnt-labs-arm64
# platform: linux/arm64
os:
- linux
arch:
- amd64
# - arm64
test_type:
- "DungeonTransferBlock"
- "XionSendPlatformFee"
- "MintModuleNoInflationNoFees"
- "MintModuleInflationHighFees"
- "MintModuleInflationLowFees"
- "JWTAbstractAccount"
- "XionSendPlatformFee"
- "XionAbstractAccount"
- "WebAuthNAbstractAccount"
- "XionMinimumFeeDefault"
- "XionMinimumFeeZero"
- "XionTokenFactory"
- "XionAbstractAccountJWTCLI"
- "TreasuryContract"
- "TreasuryMulti"
- "SingleAbstractAccountMigration"
# - "Simulate"
- "DungeonTransferBlock"
- "XionSendPlatformFee"
- "MintModuleNoInflationNoFees"
- "MintModuleInflationHighFees"
- "MintModuleInflationLowFees"
- "JWTAbstractAccount"
- "XionSendPlatformFee"
- "XionAbstractAccount"
- "WebAuthNAbstractAccount"
- "XionMinimumFeeDefault"
- "XionMinimumFeeZero"
- "XionTokenFactory"
- "XionAbstractAccountJWTCLI"
- "TreasuryContract"
- "TreasuryMulti"
- "SingleAbstractAccountMigration"
# - "Simulate"

steps:
- name: checkout
Expand All @@ -107,13 +109,13 @@ jobs:
OS: ${{ steps.string.outputs.lowercase }}
run: |
mkdir -p lib
echo "PLATFORM=${{ matrix.runner.platform }}" | tr '/' '-' | tee -a $GITHUB_ENV
echo "PLATFORM=${{ matrix.os }}/${{ matrix.arch }}" | tr '/' '-' | tee -a $GITHUB_ENV
- name: Download integration test binary
uses: actions/download-artifact@v4
with:
path: integration_tests
pattern: test-${{ env.PLATFORM }}
pattern: test-${{ matrix.os }}-${{ matrix.arch }}
merge-multiple: true

- name: Download wasm vm lib
Expand All @@ -127,7 +129,7 @@ jobs:
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}
pattern: heighliner-${{ env.PLATFORM }}.tar
pattern: heighliner-${{ matrix.os }}-${{ matrix.arch }}.tar
merge-multiple: true

- name: Load images
Expand All @@ -143,4 +145,4 @@ jobs:
./integration_tests/integration_tests.test -test.failfast -test.v -test.run Test${{ matrix.test_type }}
env:
E2E_SKIP_CLEANUP: true
XION_IMAGE: heighliner:${{ env.PLATFORM }}
XION_IMAGE: heighliner:${{ matrix.os }}-${{ matrix.arch }}
Loading

0 comments on commit 9e3d114

Please sign in to comment.