Release #363
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| goreleaser: | |
| description: Create Github release artifacts | |
| required: true | |
| type: boolean | |
| releaseType: | |
| description: Release type | |
| required: true | |
| type: choice | |
| options: [dev, release] | |
| env: | |
| GO_VERSION: "1.26" | |
| jobs: | |
| goreleaser: | |
| name: Create Github release | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.releaseType == 'release' && github.event.inputs.goreleaser | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Check for existing release | |
| uses: actions/github-script@v9 | |
| id: check-release | |
| with: | |
| script: | | |
| const { execSync } = require('child_process'); | |
| // Get the latest reachable tag | |
| const tagName = execSync('git describe --tags --abbrev=0', { encoding: 'utf-8' }).trim(); | |
| core.info(`Found tag: ${tagName}`); | |
| // Check if a GitHub release exists for this tag | |
| try { | |
| const { data: release } = await github.rest.repos.getReleaseByTag({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag: tagName | |
| }); | |
| core.warning(`⚠️ Release ${tagName} already exists (ID: ${release.id}, created: ${release.created_at})`); | |
| core.warning(`Release URL: ${release.html_url}`); | |
| core.setOutput('skip_release', 'true'); | |
| core.setOutput('tag_name', tagName); | |
| } catch (error) { | |
| if (error.status === 404) { | |
| core.info(`✓ No existing release found for ${tagName}. Proceeding with release.`); | |
| core.setOutput('skip_release', 'false'); | |
| core.setOutput('tag_name', tagName); | |
| } else { | |
| core.warning(`Error checking for existing release: ${error.message}`); | |
| core.warning('Allowing release to proceed due to API error.'); | |
| core.setOutput('skip_release', 'false'); | |
| core.setOutput('tag_name', tagName); | |
| } | |
| } | |
| - name: Skip notice | |
| if: steps.check-release.outputs.skip_release == 'true' | |
| run: | | |
| echo "::warning::Skipping goreleaser step because release ${{ steps.check-release.outputs.tag_name }} already exists" | |
| echo "To create a new release, either:" | |
| echo " 1. Create a new version tag, or" | |
| echo " 2. Manually delete the existing release from GitHub" | |
| - name: Setup Go ${{ env.GO_VERSION }} | |
| if: steps.check-release.outputs.skip_release != 'true' | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Build docs | |
| if: steps.check-release.outputs.skip_release != 'true' | |
| run: make docs | |
| - name: Run goreleaser | |
| if: steps.check-release.outputs.skip_release != 'true' | |
| uses: goreleaser/goreleaser-action@v7 | |
| with: | |
| version: latest | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| docker: | |
| name: Build Docker images | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Login to container registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| with: | |
| platforms: linux/amd64,linux/arm64/v8 | |
| - name: Setup buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Docker meta | |
| uses: docker/metadata-action@v6 | |
| id: meta | |
| with: | |
| images: ghcr.io/digineo/texd | |
| tags: | | |
| type=semver,pattern=v{{version}} | |
| type=semver,pattern=v{{major}} | |
| latest | |
| - name: Release meta | |
| uses: actions/github-script@v9 | |
| id: release-meta | |
| with: | |
| script: | | |
| const isRelease = context.payload.inputs.releaseType === 'release' ? '1' : '0' | |
| return { isRelease } | |
| - name: Docker image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| file: ./.github/Dockerfile.release | |
| build-args: | | |
| GO_VERSION=${{ env.GO_VERSION }} | |
| IS_RELEASE=${{ steps.release-meta.outputs.result.isRelease }} | |
| platforms: linux/amd64,linux/arm64/v8 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| context: . |