Skip to content

[Dispatch] Release

[Dispatch] Release #21

name: "[Dispatch] Release"
on:
workflow_dispatch:
inputs:
version:
description: "enter version (1.0.0 format, without 'v' prefix)"
required: true
default: "0.0.0"
container_arch:
type: choice
description: "choose container architecture"
default: linux/amd64
options:
- "linux/amd64"
- "linux/amd64,linux/arm64"
env:
ARCH: ${{ github.event.inputs.container_arch }}
VERSION: ${{ github.event.inputs.version }}
PACKAGE_VERSION: ${{ github.event.inputs.version }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
jobs:
set-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- name: Set version
id: set-version
run: |
VERSION="${{ github.event.inputs.version }}"
# Remove 'v' prefix if present
VERSION="${VERSION#v}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
tagging:
needs: set-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT_TOKEN }}
- name: tagging
run: |
git config user.email admin@cloudforet.io
git config user.name cloudforet-admin
git tag v${{ needs.set-version.outputs.version }}
git push origin v${{ needs.set-version.outputs.version }}
- name: Notice when job fails
if: failure()
uses: 8398a7/action-slack@v3.15.0
with:
status: ${{job.status}}
fields: repo,workflow,job
author_name: Github Action Slack
build:
needs: tagging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.23.1"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
- name: Notice when job fails
if: failure()
uses: 8398a7/action-slack@v3.15.0
with:
status: ${{job.status}}
fields: repo,workflow,job
author_name: Github Action Slack
docker:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.CLOUDFORET_DEV_DOCKER_USERNAME }}
password: ${{ secrets.CLOUDFORET_DEV_DOCKER_PASSWORD }}
- name: Build and push to dockerhub
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ env.ARCH }}
push: true
tags: |
cloudforet/${{ github.event.repository.name }}:latest
cloudforet/${{ github.event.repository.name }}:v${{ env.VERSION }}
- name: Notice when job fails
if: failure()
uses: 8398a7/action-slack@v3.15.0
with:
status: ${{job.status}}
fields: repo,workflow,job
author_name: Github Action Slack
notification:
needs: docker
runs-on: ubuntu-latest
steps:
- name: Slack
if: always()
uses: 8398a7/action-slack@v3.15.0
with:
status: ${{job.status}}
fields: repo,message,commit,author,action,ref,workflow,job
author_name: Github Action Slack