feat: [DEVOPS-42674] support specify ssh endpoint #28
Workflow file for this run
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: Build and Release | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| tags: [ 'v*' ] | |
| paths: | |
| - 'cmd/**' | |
| - 'internal/**' | |
| - 'pkg/**' | |
| - 'go.mod' | |
| - 'go.sum' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'cmd/**' | |
| - 'internal/**' | |
| - 'pkg/**' | |
| - 'go.mod' | |
| - 'go.sum' | |
| env: | |
| BINARY_NAME: gitlab-cli | |
| jobs: | |
| build: | |
| name: Build Binary | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| # Linux | |
| - os: ubuntu-latest | |
| goos: linux | |
| goarch: amd64 | |
| artifact_name: gitlab-cli-linux-amd64 | |
| - os: ubuntu-latest | |
| goos: linux | |
| goarch: arm64 | |
| artifact_name: gitlab-cli-linux-arm64 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| cache: true | |
| - name: Get version info | |
| id: version | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=dev-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT | |
| fi | |
| echo "commit=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT | |
| echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
| - name: Build binary | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: 0 | |
| run: | | |
| go build \ | |
| -ldflags="-s -w -X main.Version=${{ steps.version.outputs.version }}" \ | |
| -o "${{ matrix.artifact_name }}" \ | |
| ./cmd/gitlab-cli | |
| - name: Generate checksum | |
| run: | | |
| if [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
| shasum -a 256 "${{ matrix.artifact_name }}" > "${{ matrix.artifact_name }}.sha256" | |
| else | |
| sha256sum "${{ matrix.artifact_name }}" > "${{ matrix.artifact_name }}.sha256" | |
| fi | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: | | |
| ${{ matrix.artifact_name }} | |
| ${{ matrix.artifact_name }}.sha256 | |
| retention-days: 30 | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist/ | |
| - name: Prepare release assets | |
| run: | | |
| mkdir -p release | |
| find dist/ -type f -exec cp {} release/ \; | |
| ls -lah release/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| body: | | |
| ## GitLab CLI ${{ github.ref_name }} | |
| GitLab 用户和项目自动化管理工具 | |
| ### 安装 | |
| 下载对应平台的二进制文件,解压后即可使用: | |
| ```bash | |
| # Linux (amd64) | |
| wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gitlab-cli-linux-amd64 | |
| chmod +x gitlab-cli-linux-amd64 | |
| sudo mv gitlab-cli-linux-amd64 /usr/local/bin/gitlab-cli | |
| # macOS (arm64, Apple Silicon) | |
| wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gitlab-cli-darwin-arm64 | |
| chmod +x gitlab-cli-darwin-arm64 | |
| sudo mv gitlab-cli-darwin-arm64 /usr/local/bin/gitlab-cli | |
| ``` | |
| ### 验证安装 | |
| ```bash | |
| gitlab-cli --version | |
| ``` | |
| ### 文档 | |
| - [快速开始](https://github.com/${{ github.repository }}/blob/main/docs/QUICKSTART.md) | |
| - [完整文档](https://github.com/${{ github.repository }}/blob/main/docs/README.md) | |
| - [架构设计](https://github.com/${{ github.repository }}/blob/main/docs/ARCHITECTURE.md) |