Merge pull request #3 from shadyeip/ci/auto-release-on-main

ci: auto-release with date-based versioning on merge to main
This commit is contained in:
Adam Nadrowski
2026-02-09 12:48:03 -05:00
committed by GitHub

View File

@@ -2,13 +2,15 @@ name: release
on: on:
push: push:
branches:
- main
tags: tags:
- "v*" - "v*"
workflow_dispatch: workflow_dispatch:
inputs: inputs:
tag: tag:
description: "Version tag to release (e.g. v1.0.0)" description: "Version tag to release (e.g. v2026.02.09)"
required: true required: false
type: string type: string
jobs: jobs:
@@ -40,17 +42,28 @@ jobs:
id: version id: version
working-directory: terraform-provider-unifi working-directory: terraform-provider-unifi
run: | run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then if [ -n "${{ inputs.tag }}" ]; then
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" TAG="${{ inputs.tag }}"
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
else else
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" # 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 fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Create tag (workflow_dispatch only) - name: Create and push tag
if: github.event_name == 'workflow_dispatch' if: ${{ !startsWith(github.ref, 'refs/tags/') }}
working-directory: terraform-provider-unifi working-directory: terraform-provider-unifi
run: | run: |
git tag "${{ steps.version.outputs.tag }}" git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: Import GPG key - name: Import GPG key
if: env.GPG_PRIVATE_KEY != '' if: env.GPG_PRIVATE_KEY != ''