Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,25 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Check for Git tag
id: check_tag
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "TAG_PRESENT=true" >> $GITHUB_OUTPUT
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [[ -n "$LATEST_TAG" ]]; then
echo "TAG_PRESENT=false" >> $GITHUB_OUTPUT
echo "TAG_NAME=$LATEST_TAG" >> $GITHUB_OUTPUT
else
echo "TAG_PRESENT=false" >> $GITHUB_OUTPUT
echo "TAG_NAME=v0.0.0" >> $GITHUB_OUTPUT
fi
fi

- name: Login to GitHub Container Registry
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && inputs.dry_run == false)
uses: docker/login-action@v3
with:
registry: ghcr.io
Expand All @@ -64,9 +81,21 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}

- name: Run GoReleaser (Manual Release)
if: github.event_name == 'workflow_dispatch' && inputs.dry_run == false
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean ${{ steps.check_tag.outputs.TAG_PRESENT == 'false' && '--snapshot' || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}

- name: Run GoReleaser (Dry Run)
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.dry_run)
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.dry_run == true)
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
Expand Down
16 changes: 16 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ changelog:
- '^chore:'
- '^ci:'

brews:
- name: azswitch
repository:
owner: l2D
name: homebrew-tap
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
directory: Formula
homepage: "https://github.com/l2D/azswitch"
description: "Switch Azure Directory and Subscription with command and TUI"
license: "MIT"
install: |
bin.install "azswitch"
test: |
system "#{bin}/azswitch", "--version"
commit_msg_template: "chore(formula): update {{ .ProjectName }} to version {{ .Tag }}"

release:
github:
owner: l2D
Expand Down