feat: add scheduled binary release workflow

This commit is contained in:
Prad Nukala
2024-09-30 15:13:00 -04:00
parent 49e56239a5
commit d7d19f4bb7
22 changed files with 138 additions and 1716 deletions
-73
View File
@@ -1,73 +0,0 @@
name: Publish Docker Image
on:
push:
branches:
- master
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # ignore rc
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
GO_VERSION: 1.22
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write
jobs:
release-image:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# all lowercase ghcr registry
- run: |
DOCKER_REGISTRY=`echo "${{ env.REGISTRY }}/${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
echo "DOCKER_REGISTRY=$DOCKER_REGISTRY" >> $GITHUB_ENV
REPO_NAME=`echo "${{ github.repository }}" | awk -F'/' '{print $2}' | tr '[:upper:]' '[:lower:]'`
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
- name: Parse tag
id: tag
run: |
# v0.0.1
VERSION=$(echo ${{ github.ref_name }} | sed "s/v//")
# 0.0.1
echo "VERSION=$VERSION" >> $GITHUB_ENV
# build and publish package to ghcr (public) with codebase remaining private
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT_TOKEN }}
# make sure to update package to be public in repo ghcr settings
- name: Build and push Docker image
uses: strangelove-ventures/heighliner-build-action@v1.0.0
with:
# v0.0.1
git-ref: ${{ github.ref_name }}
chain: ${{ env.REPO_NAME}}
dockerfile: cosmos
registry: ${{ env.DOCKER_REGISTRY }}
build-target: |
cd ..
make install
local: true
binaries: |
- /go/bin/sonrd
build-env: |
- BUILD_TAGS=muslc
-47
View File
@@ -1,47 +0,0 @@
name: "Release Binary"
# Pairs with .goreleaser.yaml file for configuration.
on:
push:
branches:
- master
tags:
- v*
permissions:
contents: write
jobs:
goreleaser:
if: false
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: "1.22"
check-latest: true
- name: Clean up dist directory
run: rm -rf dist
- name: Build
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: build --skip-validate
- name: Release
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --skip-validate --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
+62
View File
@@ -0,0 +1,62 @@
name: "Release Binary"
on:
push:
branches:
- master
tags:
- v*
permissions:
contents: write
jobs:
goreleaser:
if: false
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get latest tag
run: |
# Fetch all tags
git fetch --tags
# Get the latest tag
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Latest Tag: $LATEST_TAG"
# Checkout the latest tag
git checkout $LATEST_TAG
- name: Check if release exists
id: check_release
run: |
TAG_NAME=${{ env.latest_tag }}
echo "Checking for existing release for tag: $TAG_NAME"
RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GH_PAT_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG_NAME")
if echo "$RESPONSE" | grep -q '"id":'; then
echo "Release already exists for tag $TAG_NAME."
echo "release_exists=true" >> $GITHUB_ENV
else
echo "No release found for tag $TAG_NAME."
echo "release_exists=false" >> $GITHUB_ENV
fi
- uses: actions/setup-go@v5
with:
go-version: "1.22"
check-latest: true
- name: Release
if: env.release_exists == 'false'
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser-pro
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}