Skip to content

Fix permissions to push to ghcr.io (#493) #25

Fix permissions to push to ghcr.io (#493)

Fix permissions to push to ghcr.io (#493) #25

Workflow file for this run

name: Release Workflow
on:
push:
tags:
- "v*"
env:
CGO_ENABLED: 0
GO_VERSION: '1.25'
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: write
packages: write
jobs:
build-image:
name: Build and push image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
run: make image-build-push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
name: Release
runs-on: ubuntu-latest
needs:
- build-image
steps:
- name: Checkout code
uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Create manifests
run: make release
- name: Generate Release Notes
run: |
release_notes=$(gh api repos/{owner}/{repo}/releases/generate-notes -F tag_name=${{ github.ref }} --jq .body)
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_ENV
echo "${release_notes}" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: out/release/*
body: ${{ env.RELEASE_NOTES }}
draft: false
prerelease: false