Skip to content

Update go

Update go #94

Workflow file for this run

name: release
on:
push:
branches:
- master
jobs:
build-linux:
name: Build Linux
runs-on: ubuntu-latest
outputs:
version: ${{ env.VERSION }}
steps:
- name: stuffs
run: |
# https://developer.github.com/webhooks/#events
echo "comment: ${{ github.event.commits[0].message }}"
- name: skip check
if: contains( github.event.commits[0].message, 'skip ci' )
# good functions and things here: https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions#functions
run: |
echo "exiting, skip ci found"
exit 78
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21
id: go
- name: Bump version
run: |
git config --global user.email "ci@gochain.io"
git config --global user.name "CI"
git fetch --tags
wget -O - https://raw.githubusercontent.com/treeder/bump/master/gitbump.sh | bash
echo "VERSION=$(git tag --sort=-v:refname --list 'v[0-9]*' | head -n 1 | cut -c 2-)" >> $GITHUB_ENV
- name: Binary build
run: |
echo "Version: $VERSION"
# Linux x86 build
CGO_ENABLED=1 GOOS=linux go build -ldflags "-X main.Version=$VERSION" -o web3_linux ./cmd/web3
# Linux arm64build
sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu
CGO_ENABLED=1 GOOS=linux GOARCH="arm64" CC=aarch64-linux-gnu-gcc go build -ldflags "-X main.Version=$VERSION" -o web3_linux_arm64 ./cmd/web3
# Alpine build
docker create -v /data --name web3_sources alpine /bin/true
docker cp -a . web3_sources:/data/
docker build -t gochain/builder:latest -f Dockerfile.build .
docker run --rm --volumes-from web3_sources -w /data gochain/builder go build -ldflags "-X main.Version=$VERSION" -o web3_alpine ./cmd/web3
docker cp web3_sources:/data/web3_alpine web3_alpine
# docker rm -f web3_sources
- name: GitHub release
uses: ncipollo/release-action@v1
with:
artifacts: "web3_linux, web3_alpine, web3_alpine, web3_linux_arm64"
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ env.VERSION }}
name: ${{ env.VERSION }}
- name: Docker release
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
run: |
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
docker build -t gochain/web3:latest .
docker tag gochain/web3:latest gochain/web3:$VERSION
docker push gochain/web3:$VERSION
docker push gochain/web3:latest
build-mac:
name: Build MacOS
runs-on: macOS-latest
needs: build-linux
env:
VERSION: ${{ needs.build-linux.outputs.version }}
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: build
run: |
go build -ldflags "-X main.Version=$VERSION" -o web3_mac ./cmd/web3
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -ldflags "-X main.Version=$VERSION" -o web3_mac_arm64 ./cmd/web3
- name: release
uses: ncipollo/release-action@v1
with:
artifacts: "web3_mac, web3_mac_arm64"
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ env.VERSION }}
name: ${{ env.VERSION }}
allowUpdates: true
omitNameDuringUpdate: true