Skip to content

updates to make this more useful #9

updates to make this more useful

updates to make this more useful #9

Workflow file for this run

name: Release Terraform Provider
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
wait_ci:
name: Wait for CI success on tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine tag and SHA
id: ref
shell: bash
run: |
TAG="${{ github.ref_type == 'tag' && github.ref_name || '' }}"
if [[ -z "$TAG" ]]; then
echo "Error: no tag in event" >&2
exit 1
fi
SHA="${{ github.sha }}"
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "sha=$SHA" >> $GITHUB_OUTPUT
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Wait for CI workflow
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
SHA="${{ steps.ref.outputs.sha }}"
echo "Waiting for CI to succeed for $SHA ..."
ATTEMPTS=120
SLEEP=10
for i in $(seq 1 $ATTEMPTS); do
RESP=$(curl -s -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs?per_page=50&head_sha=$SHA")
STATUS=$(echo "$RESP" | jq -r '.workflow_runs[] | select(.name=="CI") | .status' | head -n1)
CONCLUSION=$(echo "$RESP" | jq -r '.workflow_runs[] | select(.name=="CI") | .conclusion' | head -n1)
if [[ "$STATUS" == "completed" ]]; then
if [[ "$CONCLUSION" == "success" ]]; then
echo "CI succeeded."
exit 0
else
echo "CI completed with conclusion: $CONCLUSION"
exit 1
fi
fi
echo "CI status: ${STATUS:-not found}; waiting... ($i/$ATTEMPTS)"
sleep $SLEEP
done
echo "Timed out waiting for CI to complete."
exit 1
goreleaser:
runs-on: ubuntu-latest
needs: wait_ci
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: v2.12.0
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}