Skip to content

fix(ci): ci fixed

fix(ci): ci fixed #27

Workflow file for this run

name: Test, Build and Release
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24.3'
- name: Ensure go mod tidy has zero output
run: go mod tidy -v && git diff --exit-code
- name: Ensure gofumpt has zero output
run: |
go install mvdan.cc/gofumpt@latest
gofumpt -l -w .
git diff --exit-code
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-pkg-cache: true
args: --issues-exit-code=0
- name: Build with version info
run: |
TAG=$(git describe --tags --always)
COMMIT=$(git rev-parse --short HEAD)
DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
go build -ldflags="\
-X github.com/apiqube/cli/cmd/cli.version=$TAG \
-X github.com/apiqube/cli/cmd/cli.commit=$COMMIT \
-X github.com/apiqube/cli/cmd/cli.date=$DATE" \
-o qube ./cmd/qube
./qube version
mkdir -p bin
mv qube bin/
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: qube-binaries
path: bin/qube
if-no-files-found: error
release:
needs: build-and-test
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.get_tag.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24.3'
- name: Run go-semantic-release
uses: go-semantic-release/action@v1
with:
hooks: goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch tags
run: git fetch --tags
- name: Get latest tag or fallback
id: get_tag
run: |
TAG=$(git describe --tags --abbrev=0 || echo "v1.0.0")
echo "tag=$TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Build release binaries
run: |
TAG=$(git describe --tags --always)
COMMIT=$(git rev-parse --short HEAD)
DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
go build -ldflags="\
-X github.com/apiqube/cli/cmd/qube.version=$TAG \
-X github.com/apiqube/cli/cmd/qube.commit=$COMMIT \
-X github.com/apiqube/cli/cmd/qube.date=$DATE" \
-o qube ./cmd/qube
./qube version
- name: Create GitHub Release (if not exists)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.get_tag.outputs.tag }}
run: |
if [ -n "$VERSION" ]; then
gh release view "$VERSION" >/dev/null 2>&1 || \
gh release create "$VERSION" --generate-notes
else
echo "No new tag created, skipping release step."
fi