From 2ff2d915dac011534143e6187a529ab7966828b9 Mon Sep 17 00:00:00 2001 From: Hamish Forbes Date: Thu, 19 Sep 2024 20:20:48 +1200 Subject: [PATCH] GHA Add publish and release process to Spacelift --- .github/workflows/release.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 78b0b15..3d5a612 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -38,3 +38,27 @@ jobs: # GitHub sets the GITHUB_TOKEN secret automatically. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + + - name: Release new version to spacelift + if: startsWith(github.ref, 'refs/tags/') + env: + GPG_KEY_ID: ${{ steps.import_gpg.outputs.keyid }} + SPACELIFT_API_KEY_ENDPOINT: https://spacelift.ktl.net + SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }} + SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }} + run: + spacectl provider create-version --type=nexus + + - name: Publish provider + if: startsWith(github.ref, 'refs/tags/') + env: + GPG_KEY_ID: ${{ steps.import_gpg.outputs.keyid }} + SPACELIFT_API_KEY_ENDPOINT: https://spacelift.ktl.net + SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }} + SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }} + run: | + spacectl provider list-versions --type nexus -o json > versions.json + VERSION_NUMBER=${{ github.ref_name }} + VERSION_ID=$(jq -r --arg version "${VERSION_NUMBER#v}" '.versions[] | select(.number == $version) | .id' versions.json) + echo "Publishing ID: $VERSION_ID" + spacectl provider publish-version --version=$VERSION_ID \ No newline at end of file