stages: - build - release variables: APP_NAME: greq GO_VERSION: "1.23" # ── Build binaries for all platforms ────────────────────────────────────────── .build_template: &build_template stage: build image: golang:${GO_VERSION} before_script: - go version - go mod download only: - tags build:linux-amd64: <<: *build_template script: - GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version=${CI_COMMIT_TAG}" -o dist/${APP_NAME}-linux-amd64 . artifacts: paths: - dist/${APP_NAME}-linux-amd64 expire_in: 1 hour build:linux-arm64: <<: *build_template script: - GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.version=${CI_COMMIT_TAG}" -o dist/${APP_NAME}-linux-arm64 . artifacts: paths: - dist/${APP_NAME}-linux-arm64 expire_in: 1 hour build:darwin-amd64: <<: *build_template script: - GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.version=${CI_COMMIT_TAG}" -o dist/${APP_NAME}-darwin-amd64 . artifacts: paths: - dist/${APP_NAME}-darwin-amd64 expire_in: 1 hour build:darwin-arm64: <<: *build_template script: - GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version=${CI_COMMIT_TAG}" -o dist/${APP_NAME}-darwin-arm64 . artifacts: paths: - dist/${APP_NAME}-darwin-arm64 expire_in: 1 hour build:windows-amd64: <<: *build_template script: - GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.version=${CI_COMMIT_TAG}" -o dist/${APP_NAME}-windows-amd64.exe . artifacts: paths: - dist/${APP_NAME}-windows-amd64.exe expire_in: 1 hour # ── Create GitLab Release with all binaries ─────────────────────────────────── release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest needs: - job: build:linux-amd64 artifacts: true - job: build:linux-arm64 artifacts: true - job: build:darwin-amd64 artifacts: true - job: build:darwin-arm64 artifacts: true - job: build:windows-amd64 artifacts: true script: - echo "Creating release ${CI_COMMIT_TAG}" release: tag_name: ${CI_COMMIT_TAG} name: "greq ${CI_COMMIT_TAG}" description: | ## greq ${CI_COMMIT_TAG} A terminal-based HTTP client with a TUI interface. ### Download | Platform | Architecture | File | |----------------|--------------|-----------------------------------------| | Linux | x86_64 | `greq-linux-amd64` | | Linux | ARM64 | `greq-linux-arm64` | | macOS | x86_64 | `greq-darwin-amd64` | | macOS | Apple Silicon| `greq-darwin-arm64` | | Windows | x86_64 | `greq-windows-amd64.exe` | ### Install (Linux/macOS) ```bash chmod +x greq-* sudo mv greq-* /usr/local/bin/greq ``` assets: links: - name: "greq-linux-amd64" url: "${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/greq-linux-amd64?job=build:linux-amd64" link_type: package - name: "greq-linux-arm64" url: "${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/greq-linux-arm64?job=build:linux-arm64" link_type: package - name: "greq-darwin-amd64" url: "${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/greq-darwin-amd64?job=build:darwin-amd64" link_type: package - name: "greq-darwin-arm64" url: "${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/greq-darwin-arm64?job=build:darwin-arm64" link_type: package - name: "greq-windows-amd64.exe" url: "${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/greq-windows-amd64.exe?job=build:windows-amd64" link_type: package only: - tags