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

Releasing artifacts: with goreleaser #444

Merged
merged 9 commits into from
Feb 21, 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
27 changes: 0 additions & 27 deletions .github/workflows/build_docker.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/goreleaser-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: goreleaser-latest

on:
push:
branches:
- main
- develop

permissions:
contents: write
packages: write

jobs:
goreleaser-latest:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --force --tags

- name: Release (snapshot)
run: make release-snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Login to GHCR container register
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push versioned image
uses: docker/build-push-action@v5
with:
file: contrib/docker/goreleaser.Dockerfile
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/composablefi/composable-cosmos:latest
55 changes: 55 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: goreleaser

on:
push:
tags:
- "*"

permissions:
contents: write
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --force --tags

- name: Release
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get version
id: get_version
uses: battila7/get-version-action@v2

- name: Login to GHCR container register
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push versioned image
uses: docker/build-push-action@v5
with:
file: contrib/docker/goreleaser.Dockerfile
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/composablefi/composable-cosmos:${{ steps.get_version.outputs.version }}
ghcr.io/composablefi/composable-cosmos:v${{ steps.get_version.outputs.major }}
ghcr.io/composablefi/composable-cosmos:v${{ steps.get_version.outputs.major }}.${{ steps.get_version.outputs.minor }}
65 changes: 0 additions & 65 deletions .github/workflows/push_docker_images.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/release.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ scripts/temp.sh
wasm_client*
vue/*
bin/*

dist/

# Test binary, built with `go test -c`
*.test

Expand Down
81 changes: 81 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# .goreleaser.yml

project_name: centaurid

env:
- CGO_ENABLED=1

builds:
- id: linux
main: ./cmd/centaurid
binary: centaurid
hooks:
pre:
- cmd: bash scripts/release_pre_linux.sh
output: false # enable for debug
env:
- TARGET={{ .Target }}
goos:
- linux
goarch:
- amd64
- arm64
env:
- CC_linux_amd64=x86_64-linux-gnu-gcc
- CC_linux_arm64=aarch64-linux-gnu-gcc
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
flags:
- -mod=readonly
- -trimpath
ldflags:
- -X github.com/cosmos/cosmos-sdk/version.Name=centauri
- -X github.com/cosmos/cosmos-sdk/version.AppName=centaurid
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc"
- -w -s
- -linkmode=external
- -extldflags '-static -lm -lbz2'
tags:
- netgo
- ledger
- muslc
- static
- static_wasm

# - id: darwin
# main: ./cmd/centaurid
# binary: centaurid
# hooks:
# pre:
# - cmd: bash scripts/release_pre_darwin.sh
# output: false # enable for debug
# env:
# - TARGET={{ .Target }}
# goos:
# - darwin
# goarch:
# - amd64
# - arm64
# env:
# - CC_darwin_amd64=o64-clang
# - CC_darwin_arm64=oa64-clang
# - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
# flags:
# - -mod=readonly
# - -trimpath
# ldflags:
# - -X github.com/cosmos/cosmos-sdk/version.Name=centauri
# - -X github.com/cosmos/cosmos-sdk/version.AppName=centaurid
# - -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
# - -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
# - -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc"
# - -w -s
# - -linkmode=external
# - -extldflags '-static -lm -lbz2'
# tags:
# - netgo
# - ledger
# - muslc
# - static
# - static_wasm
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ ictest-push-wasm:
cd tests/interchaintest && go test -race -v -run TestPushWasmClientCode .

.PHONY: ictest-start-cosmos ictest-start-polkadot ictest-ibc ictest-push-wasm ictest-all

include contrib/make/release.mk
33 changes: 33 additions & 0 deletions contrib/docker/goreleaser.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM golang:1.20 AS builder

WORKDIR /root
COPY ./dist/ /root/

ARG TARGETARCH
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
cp linux_linux_arm64/centaurid /root/centaurid; \
else \
cp linux_linux_amd64_v1/centaurid /root/centaurid; \
fi

FROM alpine:latest

RUN apk --no-cache add ca-certificates jq
COPY --from=builder /root/centaurid /usr/local/bin/centaurid

RUN addgroup --gid 1025 -S composable && adduser --uid 1025 -S composable -G composable

WORKDIR /home/composable
USER composable

# rest server
EXPOSE 1317
# tendermint p2p
EXPOSE 26656
# tendermint rpc
EXPOSE 26657
# grpc
EXPOSE 9090

ENTRYPOINT ["centaurid"]
CMD [ "start" ]
Loading
Loading