Skip to content

Merge pull request #238 from topolvm/kubernetes-1.28 #27

Merge pull request #238 from topolvm/kubernetes-1.28

Merge pull request #238 from topolvm/kubernetes-1.28 #27

Workflow file for this run

name: "Release"
on:
push:
tags:
- "v*"
jobs:
release:
name: "release"
runs-on: "ubuntu-20.04"
steps:
- name: "Validate Release Version"
id: "check_version"
run: |
VERSION=$(echo $GITHUB_REF | sed -ne 's/[^0-9]*\([0-9]\+\.[0-9]\+\.[0-9]\+\(-.*\)\?\).*/\1/p')
if [ "$VERSION" = "" ]; then
# Invalid version format
exit 1
fi
if [ $(echo $VERSION | grep "-") ]; then PRERELEASE=true; else PRERELEASE=false; fi
echo "version=${VERSION}" >> ${GITHUB_OUTPUT}
echo "prerelease=${PRERELEASE}" >> ${GITHUB_OUTPUT}
- run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- run: make setup
- run: make image
- run: make tag IMAGE_TAG=${{ steps.check_version.outputs.version }}
- run: make push IMAGE_TAG=${{ steps.check_version.outputs.version }}
- name: "Push branch tag"
if: ${{ steps.check_version.outputs.prerelease == 'false' }}
run: |
BRANCH=$(echo ${{ steps.check_version.outputs.version }} | cut -d "." -f 1-2)
make tag IMAGE_TAG=$BRANCH
make push IMAGE_TAG=$BRANCH
- name: "Get previous tag"
id: get_previous_tag
run: |
# see https://docs.github.com/en/rest/git/refs?apiVersion=2022-11-28#list-matching-references
RESP=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/git/matching-refs/tags/v)
PREV_TAG=$(echo ${RESP} | jq -r '.[].ref' | awk -F "/" '{print $3}' | \
grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" | sort -V -r | tail -n +2 | head -n 1)
if [ -z "${PREV_TAG}" ]; then
echo "PREV_TAG is empty."
exit 1
fi
echo "previous_tag=${PREV_TAG}" >> ${GITHUB_OUTPUT}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Create Release"
id: create_release
run: |
# see https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release
gh api \
-H "Accept: application/vnd.github+json" \
--method POST \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/releases \
-f name="Release ${GITHUB_REF_NAME}" \
-f tag_name="${GITHUB_REF_NAME}" \
-f previous_tag_name="${{ steps.get_previous_tag.outputs.previous_tag }}" \
-F draft=true \
-F prerelease=${{ steps.check_version.outputs.prerelease }} \
-F generate_release_notes=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}