Merge pull request #7 from octoenergy/fix-provider-version-publish #5
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: | |
goreleaser: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Unshallow | |
run: git fetch --prune --unshallow | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.23.1 | |
- name: Import GPG key | |
id: import_gpg | |
uses: crazy-max/[email protected] | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
- name: Install spacectl | |
uses: spacelift-io/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run GoReleaser | |
uses: goreleaser/[email protected] | |
with: | |
distribution: goreleaser | |
version: "~> v2" | |
args: release --clean | |
env: | |
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=sendgrid | |
- 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 sendgrid -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 |