Change lvm path to nixos one #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Release" | |
on: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
prepare: | |
name: "prepare" | |
outputs: | |
version: ${{ steps.check_version.outputs.version }} | |
prerelease: ${{ steps.check_version.outputs.prerelease }} | |
image_prefix: ${{ steps.export_image_prefix.outputs.image_prefix }} | |
runs-on: "ubuntu-latest" | |
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} | |
- name: "Export IMAGE_PREFIX" | |
id: export_image_prefix | |
run: | | |
if [ "${{ secrets.IMAGE_PREFIX }}" != "" ]; then IMAGE_PREFIX=${{ secrets.IMAGE_PREFIX }}; else IMAGE_PREFIX=ghcr.io/topolvm/; fi | |
echo "IMAGE_PREFIX=${IMAGE_PREFIX}" >> ${GITHUB_OUTPUT} | |
build-images: | |
name: "build-images" | |
needs: prepare | |
uses: ./.github/workflows/build-images.yaml | |
with: | |
topolvm_version: ${{ needs.prepare.outputs.version }} | |
image_tag: ${{ needs.prepare.outputs.version }} | |
image_prefix: ${{ needs.prepare.outputs.image_prefix }} | |
push: "true" | |
release: | |
name: "release" | |
needs: [prepare, build-images] | |
runs-on: "ubuntu-20.04" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- run: make build/lvmd TOPOLVM_VERSION=${{ needs.prepare.outputs.version }} | |
- run: tar czf lvmd-${{ needs.prepare.outputs.version }}.tar.gz -C ./build lvmd | |
- name: "Push branch tag" | |
if: ${{ needs.prepare.outputs.prerelease == 'false' }} | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
BRANCH=$(echo ${{ needs.prepare.outputs.version }} | cut -d "." -f 1-2) | |
make tag IMAGE_TAG=$BRANCH ORIGINAL_IMAGE_TAG=${{ needs.prepare.outputs.version }} | |
env: | |
IMAGE_PREFIX: ${{ needs.prepare.outputs.image_prefix }} | |
- 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=${{ needs.prepare.outputs.prerelease }} \ | |
-F generate_release_notes=true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Upload Release Asset" | |
run: | | |
gh release upload ${GITHUB_REF_NAME} lvmd-${{ needs.prepare.outputs.version }}.tar.gz | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |