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
30 changes: 29 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ on:
push:
tags:
- 'v*.*.*'
pull_request:
paths:
- '.goreleaser.yml'
- 'Dockerfile*'
- '.github/workflows/release.yml'
- 'go.mod'
- 'go.sum'
- 'cmd/**'
- 'internal/**'
workflow_dispatch:
inputs:
dry_run:
description: 'Run in dry-run mode (no publish)'
required: false
default: true
type: boolean

permissions:
contents: write
Expand Down Expand Up @@ -32,17 +48,29 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
- name: Run GoReleaser (Release)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser (Dry Run)
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.dry_run)
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --snapshot --skip=publish --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Comment on lines +58 to +76
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Workflow gap when dry_run is false on manual dispatch.

When workflow_dispatch is triggered with dry_run: false, neither step will execute:

  • "Release" requires github.event_name == 'push' with a tag ref (line 59)
  • "Dry Run" requires inputs.dry_run to be true for workflow_dispatch (line 69)

If the intent is to allow manual releases without tags, consider adjusting the conditions. If manual dispatch should only support dry-run mode, consider removing the dry_run input entirely or documenting this limitation.

Option: Make dry_run always true for workflow_dispatch

If manual dispatch should always be dry-run only:

  workflow_dispatch:
    inputs:
      dry_run:
        description: 'Run in dry-run mode (no publish)'
        required: false
        default: true
        type: boolean

Consider removing the input if manual releases aren't intended, or document that actual releases require pushing a tag.

🤖 Prompt for AI Agents
In @.github/workflows/release.yml around lines 58 - 76, The workflow currently
skips both GoReleaser steps when manually dispatched with dry_run: false; update
the "Run GoReleaser (Release)" step's if to also allow manual dispatch by adding
a branch like (github.event_name == 'workflow_dispatch' && inputs.dry_run ==
'false') so actual releases run on manual dispatch, and keep the "Run GoReleaser
(Dry Run)" step conditional on (github.event_name == 'pull_request' ||
(github.event_name == 'workflow_dispatch' && inputs.dry_run == 'true'));
reference the step names "Run GoReleaser (Release)" and "Run GoReleaser (Dry
Run)" and the input inputs.dry_run when making these conditional changes.

63 changes: 21 additions & 42 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ builds:
archives:
- id: default
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
format: tar.gz
formats:
- tar.gz
format_overrides:
- goos: windows
format: zip
formats:
- zip
files:
- LICENSE
- README.md
Expand All @@ -42,7 +44,7 @@ checksum:
name_template: 'checksums.txt'

snapshot:
name_template: '{{ incpatch .Version }}-next'
version_template: '{{ incpatch .Version }}-next'

changelog:
sort: desc
Expand Down Expand Up @@ -86,42 +88,19 @@ release:
go install github.com/l2D/azswitch/cmd/azswitch@{{ .Tag }}
```

dockers:
- image_templates:
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-amd64'
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- '--pull'
- '--platform=linux/amd64'
- '--label=org.opencontainers.image.created={{.Date}}'
- '--label=org.opencontainers.image.title={{.ProjectName}}'
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
- '--label=org.opencontainers.image.version={{.Version}}'
- '--label=org.opencontainers.image.source={{.GitURL}}'
goarch: amd64

- image_templates:
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-arm64'
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- '--pull'
- '--platform=linux/arm64'
- '--label=org.opencontainers.image.created={{.Date}}'
- '--label=org.opencontainers.image.title={{.ProjectName}}'
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
- '--label=org.opencontainers.image.version={{.Version}}'
- '--label=org.opencontainers.image.source={{.GitURL}}'
goarch: arm64

docker_manifests:
- name_template: 'ghcr.io/l2d/azswitch:{{ .Tag }}'
image_templates:
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-amd64'
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-arm64'

- name_template: 'ghcr.io/l2d/azswitch:latest'
image_templates:
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-amd64'
- 'ghcr.io/l2d/azswitch:{{ .Tag }}-arm64'
dockers_v2:
- images:
- 'ghcr.io/l2d/azswitch'
dockerfile: Dockerfile.goreleaser
tags:
- '{{ .Tag }}'
- '{{ if not .IsNightly }}latest{{ end }}'
platforms:
- linux/amd64
- linux/arm64
labels:
'org.opencontainers.image.created': '{{.Date}}'
'org.opencontainers.image.title': '{{.ProjectName}}'
'org.opencontainers.image.revision': '{{.FullCommit}}'
'org.opencontainers.image.version': '{{.Version}}'
'org.opencontainers.image.source': '{{.GitURL}}'
1 change: 1 addition & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ azure-cli = "2.82.0"
gitleaks = "8.24.3"
go = "1.25.6"
golangci-lint = "2.8.0"
goreleaser = "2.13.3"
pre-commit = "4.5.1"
trivy = "0.68.2"
yamlfmt = "0.21.0"
26 changes: 26 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Dockerfile for GoReleaser - uses pre-built binary
FROM mcr.microsoft.com/azure-cli:2.82.0

LABEL org.opencontainers.image.title="azswitch"
LABEL org.opencontainers.image.description="TUI for switching Azure tenants and subscriptions"
LABEL org.opencontainers.image.source="https://github.com/l2D/azswitch"
LABEL org.opencontainers.image.licenses="MIT"

# Create non-root user
RUN tdnf install -y shadow-utils && \
groupadd -g 1000 azswitch && \
useradd -u 1000 -g azswitch -d /home/azswitch -s /bin/sh -m azswitch && \
tdnf clean all

# Copy pre-built binary from GoReleaser (dockers_v2 places binaries in $TARGETPLATFORM/)
ARG TARGETPLATFORM
COPY ${TARGETPLATFORM}/azswitch /usr/local/bin/azswitch

# Set up Azure CLI cache directory with proper ownership
RUN mkdir -p /home/azswitch/.azure && \
chown -R azswitch:azswitch /home/azswitch/.azure

USER azswitch
WORKDIR /home/azswitch

ENTRYPOINT ["/usr/local/bin/azswitch"]