Release #31
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: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| required: true | |
| type: string | |
| platforms: | |
| default: "linux,macos,windows" | |
| type: string | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref_name }} | |
| cancel-in-progress: false | |
| jobs: | |
| validate-tag-name: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate tag name format | |
| env: | |
| TAG_NAME: ${{ inputs.tag_name || github.ref_name }} | |
| run: | | |
| if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then | |
| echo "Invalid tag name format: $TAG_NAME (expected vX.Y.Z)" | |
| exit 1 | |
| fi | |
| linux: | |
| needs: validate-tag-name | |
| runs-on: ubuntu-latest | |
| if: ${{ !inputs.platforms || contains(inputs.platforms, 'linux') }} | |
| env: | |
| TAG_NAME: ${{ inputs.tag_name || github.ref_name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Install GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| version: "~> v2" | |
| install-only: true | |
| - name: Create temporary tag | |
| if: github.event_name == 'workflow_dispatch' | |
| run: git tag "$TAG_NAME" | |
| - name: Install cross-compilers | |
| run: | | |
| sudo apt-get install -y \ | |
| gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \ | |
| gcc-i686-linux-gnu g++-i686-linux-gnu \ | |
| gcc-arm-linux-gnueabi g++-arm-linux-gnueabi | |
| - name: Build release binaries | |
| run: bash script/release --local "$TAG_NAME" --platform linux | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-linux | |
| if-no-files-found: error | |
| retention-days: 7 | |
| path: | | |
| dist/*.tar.gz | |
| dist/*.rpm | |
| dist/*.deb | |
| dist/*.apk | |
| dist/*.zst | |
| macos: | |
| needs: validate-tag-name | |
| runs-on: macos-latest | |
| if: ${{ !inputs.platforms || contains(inputs.platforms, 'macos') }} | |
| env: | |
| TAG_NAME: ${{ inputs.tag_name || github.ref_name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Install GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| version: "~> v2" | |
| install-only: true | |
| - name: Create temporary tag | |
| if: github.event_name == 'workflow_dispatch' | |
| run: git tag "$TAG_NAME" | |
| - name: Build release binaries | |
| run: bash script/release --local "$TAG_NAME" --platform macos | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-darwin | |
| if-no-files-found: error | |
| retention-days: 7 | |
| path: | | |
| dist/*.tar.gz | |
| dist/*.zip | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-homebrew | |
| if-no-files-found: error | |
| retention-days: 7 | |
| path: dist/homebrew/Formula/pgxcli.rb | |
| windows: | |
| needs: validate-tag-name | |
| runs-on: windows-2022 | |
| if: ${{ !inputs.platforms || contains(inputs.platforms, 'windows') }} | |
| env: | |
| TAG_NAME: ${{ inputs.tag_name || github.ref_name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Set up MSYS2 | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| install: mingw-w64-x86_64-gcc | |
| update: true | |
| - name: Install GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| version: "~> v2" | |
| install-only: true | |
| - name: Create temporary tag | |
| shell: bash | |
| run: git tag "$TAG_NAME" | |
| if: github.event_name == 'workflow_dispatch' | |
| - name: Build release binaries | |
| shell: bash | |
| run: bash script/release --local "$TAG_NAME" --platform windows | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up MSBuild | |
| id: setupmsbuild | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Install WiX Toolset | |
| run: choco install wixtoolset -y --no-progress | |
| shell: pwsh | |
| - name: Build MSI | |
| shell: bash | |
| env: | |
| MSBUILD_PATH: ${{ steps.setupmsbuild.outputs.msbuildPath }} | |
| VERSION: ${{ env.TAG_NAME }} | |
| run: | | |
| version="${VERSION#v}" | |
| for ZIP_FILE in dist/pgxcli_*_windows_*.zip; do | |
| MSI_NAME="$(basename "$ZIP_FILE" ".zip")" | |
| case "$MSI_NAME" in | |
| *_amd64 ) | |
| source_dir="$PWD/dist/pgxcli-windows_windows_amd64_v1/" | |
| platform="x64" | |
| ;; | |
| * ) | |
| printf "unsupported architecture: %s\n" "$MSI_NAME" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| "${MSBUILD_PATH}\\MSBuild.exe" build/windows/pgxcli.wixproj \ | |
| -p:SourceDir="$source_dir" \ | |
| -p:OutputPath="$PWD/dist" \ | |
| -p:OutputName="pgxcli_${version}_windows_amd64" \ | |
| -p:ProductVersion="$version" \ | |
| -p:Platform="$platform" \ | |
| -p:Configuration=Release | |
| done | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-windows | |
| if-no-files-found: error | |
| retention-days: 7 | |
| path: | | |
| dist/*.zip | |
| dist/*.msi | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [linux, macos, windows] | |
| if: always() && !contains(needs.*.result, 'failure') | |
| env: | |
| TAG_NAME: ${{ inputs.tag_name || github.ref_name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: dist-* | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Generate checksums | |
| run: | | |
| cd dist | |
| VERSION="${TAG_NAME#v}" | |
| shasum -a 256 pgxcli_* > "pgxcli_${VERSION}_checksums.txt" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.TAG_NAME }} | |
| draft: true | |
| prerelease: ${{ contains(env.TAG_NAME, '-') }} | |
| generate_release_notes: true | |
| files: | | |
| dist/*.tar.gz | |
| dist/*.zip | |
| dist/*.msi | |
| dist/*.deb | |
| dist/*.rpm | |
| dist/*.apk | |
| dist/*.zst | |
| dist/*checksums*.txt | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish Homebrew formula | |
| if: ${{ !contains(env.TAG_NAME, '-') }} | |
| env: | |
| TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} | |
| run: | | |
| git clone https://x-access-token:${TAP_GITHUB_TOKEN}@github.com/Balaji01-4D/homebrew-pgxcli.git /tmp/homebrew-pgxcli | |
| mkdir -p /tmp/homebrew-pgxcli/Formula | |
| cp dist/homebrew/Formula/pgxcli.rb /tmp/homebrew-pgxcli/Formula/pgxcli.rb | |
| cd /tmp/homebrew-pgxcli | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/pgxcli.rb | |
| git commit -m "Brew formula update for pgxcli version ${TAG_NAME}" | |
| git push |