Files
terraform-provider-unifi/.github/workflows/release.yml
Adam Nadrowski a65f546776 ci: auto-release with date-based versioning on merge to main
Release workflow now triggers on push to main and auto-generates
date-based version tags (v2026.02.09, v2026.02.09.1, etc.).
Manual dispatch and explicit v* tags still work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 12:47:36 -05:00

88 lines
2.5 KiB
YAML

name: release
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Version tag to release (e.g. v2026.02.09)"
required: false
type: string
jobs:
release:
runs-on: ubuntu-latest
concurrency: release
permissions:
contents: write
steps:
- name: Checkout provider
uses: actions/checkout@v4
with:
fetch-depth: 0
path: terraform-provider-unifi
- name: Checkout go-unifi dependency
uses: actions/checkout@v4
with:
repository: shadyeip/go-unifi
path: go-unifi
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "terraform-provider-unifi/go.mod"
check-latest: false
- name: Determine version
id: version
working-directory: terraform-provider-unifi
run: |
if [ -n "${{ inputs.tag }}" ]; then
TAG="${{ inputs.tag }}"
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
else
# Date-based version: v2026.02.09, v2026.02.09.1, v2026.02.09.2, ...
DATE_TAG="v$(date -u +'%Y.%m.%d')"
SUFFIX=0
TAG="$DATE_TAG"
while git rev-parse "$TAG" >/dev/null 2>&1; do
SUFFIX=$((SUFFIX + 1))
TAG="${DATE_TAG}.${SUFFIX}"
done
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Create and push tag
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
working-directory: terraform-provider-unifi
run: |
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: Import GPG key
if: env.GPG_PRIVATE_KEY != ''
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: >-
release --parallelism 2 --clean
${{ steps.import_gpg.outputs.fingerprint == '' && '--skip=sign' || '' }}
workdir: terraform-provider-unifi
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}