Skip to content

Commit

Permalink
chore: add ci cd github action releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldiwildan77 committed Jul 16, 2024
1 parent 16dd975 commit be5c9bb
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Granola Release Build

on:
release:
types: [published]

workflow_dispatch:
inputs:
tag:
description: 'Tag version'
required: true

push:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
RELEASE_VERSION: ${{ github.event.release.tag_name }}
LATEST_VERSION: latest

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup go version
uses: actions/setup-go@v3
with:
go-version: '1.21.1'

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_GITHUB_TOKEN }}

- name: Sanitize environment variables
run: echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV

- name: Set output release tag by workflow_dispatch
id: dispatch
if: github.event_name == 'workflow_dispatch'
run: echo "RELEASE_VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV

- name: Set output release tag by push
id: push
if: github.event_name == 'push'
run: echo "RELEASE_VERSION=${{ github.event.head_commit.id }}" >> $GITHUB_ENV

- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RELEASE_VERSION }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.LATEST_VERSION }}

0 comments on commit be5c9bb

Please sign in to comment.