Skip to content

feat(ci): Support alpha builds #45

feat(ci): Support alpha builds

feat(ci): Support alpha builds #45

Workflow file for this run

name: goreleaser
on:
push:
branches:
- 'release/*'
tags:
- '*'
jobs:
goreleaser:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get latest release version for this release branch
if: startsWith(github.ref, 'refs/heads/release/')
id: latest_version
run: |
# Extract suffix from branch name (e.g., 'dencun' from 'release/dencun')
RELEASE_SUFFIX=${GITHUB_REF#refs/heads/release/}
# Fetch all tags and get the latest that matches the pattern
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/$GITHUB_REPOSITORY/releases" \
| jq -r --arg suffix "$RELEASE_SUFFIX" '.[] | select(.tag_name | test("^[0-9]+\\.[0-9]+\\.[0-9]+-" + $suffix + "$")) | .tag_name' \
| sort -V | tail -n 1)
echo "Found latest $RELEASE_SUFFIX version: $LATEST_VERSION"
# Default to 0.0.1 if no matching release was found
if [[ -z "$LATEST_VERSION" ]]; then
LATEST_VERSION="0.0.1"
fi
VERSION=v$LATEST_VERSION-$RELEASE_SUFFIX
echo "Releasing version: $VERSION"
git tag -a "$VERSION" -m "Release $VERSION"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.19'
- name: Install cross-compiler for linux/arm64
run: sudo apt-get -y install gcc-aarch64-linux-gnu
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Context for Buildx
shell: bash
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: builders
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}