Skip to content

fix release creation target commit (#15) #18

fix release creation target commit (#15)

fix release creation target commit (#15) #18

Workflow file for this run

name: Release
on:
push:
tags:
- 'releases/*.*.*'
branches:
- 'releases/*.*.*'
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-20.04
permissions:
contents: write
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ github.ref_name }}
- name: Determine version
id: version
run: |
REF="${GITHUB_REF_NAME#releases/}"
echo "VERSION=${REF}" >> $GITHUB_ENV
- name: Build container image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: toolbox
tags: ${{ env.VERSION }} latest
containerfiles: |
./Containerfile
oci: true
- name: Push image to GitHub Container Registry
id: push
uses: redhat-actions/push-to-registry@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: "ghcr.io/${{ github.repository_owner }}"
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
- name: Echo outputs
run: |
echo "${{ toJSON(steps.push.outputs) }}"
- name: Create release
run: |
set -x
RELEASE_ID=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.VERSION }}" | jq -r '.id')
if [ -n "$RELEASE_ID" ]; then
curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}"
fi
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/releases" \
-d "$(jq -c -n --arg tag_name "${{ env.VERSION }}" --arg ref "${GITHUB_REF_NAME}" '{"name":$tag_name,"tag_name":$tag_name,"generate_release_notes":true,"target_commitish":$ref}')"