Skip to content

Enhance proposal task error handling in tbtcpg (#3862) #6

Enhance proposal task error handling in tbtcpg (#3862)

Enhance proposal task error handling in tbtcpg (#3862) #6

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Fetch the whole history for the `git describe` command to work.
fetch-depth: 0
- name: Resolve versions
run: |
echo "version=$(git describe --tags --match 'v[0-9]*' HEAD)" \
>> $GITHUB_ENV
echo "revision=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker Build Image
uses: docker/build-push-action@v5
with:
target: build-docker
tags: go-build-env
build-args: |
VERSION=${{ env.version }}
REVISION=${{ env.revision }}
# load image to local registry to use it in next steps
load: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
context: .
- name: Run Go tests
run: |
docker run \
--workdir /go/src/github.com/keep-network/keep-core \
go-build-env \
gotestsum -- -timeout 15m
- name: Build Client Binaries
uses: docker/build-push-action@v5
with:
target: output-bins
outputs: type=local,dest=./out/bin/
build-args: |
ENVIRONMENT=mainnet
VERSION=${{ env.version }}
REVISION=${{ env.revision }}
push: false
context: .
- name: Generate release notes
id: release_notes
run: |
# Get the previous tag for release notes
PREV_TAG=$(git describe --tags --abbrev=0 --match 'v[0-9]*' \
HEAD^ 2>/dev/null || echo "")
# Create release notes
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
echo "## Keep Core ${{ env.version }}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "Built from commit: ${{ env.revision }}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "### Downloads" >> $GITHUB_OUTPUT
echo "- **Linux AMD64**: \`keep-client-mainnet-${{ env.version }}-linux-amd64.tar.gz\`" \
>> $GITHUB_OUTPUT
echo "- **macOS AMD64**: \`keep-client-mainnet-${{ env.version }}-darwin-amd64.tar.gz\`" \
>> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "### Verification" >> $GITHUB_OUTPUT
echo "All binaries include MD5 and SHA256 checksums for verification." \
>> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
if [ -n "$PREV_TAG" ]; then
echo "### Changes since $PREV_TAG" >> $GITHUB_OUTPUT
git log --oneline --no-merges "$PREV_TAG..HEAD" | head -20 \
>> $GITHUB_OUTPUT
fi
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ env.version }}
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
files: |
out/bin/*.tar.gz
out/bin/*.md5
out/bin/*.sha256
draft: false
prerelease: ${{ contains(env.version, '-') }}
generate_release_notes: false
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
publish-docker-images:
needs: build-and-release
runs-on: ubuntu-latest
environment: keep-production # Requires release-admin team approval
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve versions
run: |
echo "version=$(git describe --tags --match 'v[0-9]*' HEAD)" >> $GITHUB_ENV
echo "revision=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "dockerhub_org=${DOCKERHUB_ORG:-thresholdnetwork}" >> $GITHUB_ENV
env:
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-docker-
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Images
uses: docker/build-push-action@v5
with:
target: runtime-docker
tags: |
${{ env.dockerhub_org }}/keep-client:latest
${{ env.dockerhub_org }}/keep-client:${{ env.version }}
${{ env.dockerhub_org }}/keep-client:mainnet
labels: |
version=${{ env.version }}
revision=${{ env.revision }}
build-args: |
ENVIRONMENT=mainnet
VERSION=${{ env.version }}
REVISION=${{ env.revision }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-docker-new
context: .
- name: Move Docker cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-docker-new /tmp/.buildx-cache