Skip to content

Publish Package

Publish Package #20

Workflow file for this run

name: Publish Package
on:
release:
types:
- created
workflow_dispatch:
inputs:
tag:
description: Tag name
required: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout release
if: github.event_name != 'workflow_dispatch'
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Checkout tag
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
if: github.event_name == 'workflow_dispatch'
with:
ref: ${{ github.event.inputs.tag }}
# githun.ref_name does not update (main -> {tag-name}) after checkout (used by workflow_dispatch)
- name: Resolve tag name
id: tag_name
run: |
echo "tag_name=$(git log -n1 --pretty="format:%d" | sed "s/, /\n/g" | grep tag: | sed "s/tag: \|)//g")" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@16c0bc4a6e6ada2cfd8afd41d22d95379cf7c32a
- name: Login to GitHub Container Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
with:
push: true
build-args:
"VERSION=${{ steps.tag_name.outputs.tag_name }}"
tags: ghcr.io/kahu-app/github-action:${{ steps.tag_name.outputs.tag_name }}
cache-from: type=gha
cache-to: type=gha,mode=max