Skip to content

fix test

fix test #2

Workflow file for this run

name: Create Release
on:
push:
tags:
- 'v*'
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: true
jobs:
test:
name: 🧪 Test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Go with cache
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Run tests
run: go test -v ./...
- name: Run go vet
run: go vet ./...
build:
name: 🔨 Build Binaries
needs: [test]
strategy:
matrix:
include:
- goos: linux
goarch: amd64
runs-on: ubuntu-24.04
- goos: linux
goarch: arm64
runs-on: ubuntu-24.04
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Setup Go with cache
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Build CLI Binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
VERSION=${{ github.ref_name }}
BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S')
COMMIT=$(git rev-parse --short HEAD)
BINARY_NAME="dsearch-${{ matrix.goos }}-${{ matrix.goarch }}"
go build -ldflags "-s -w -X main.Version=${VERSION} -X main.buildTime=${BUILD_TIME} -X main.commit=${COMMIT}" \
-o "${BINARY_NAME}" ./cmd/dsearch
gzip -c "${BINARY_NAME}" > "${BINARY_NAME}.gz"
tar -czf "${BINARY_NAME}.tar.gz" "${BINARY_NAME}"
- name: Generate checksums
run: |
BINARY_NAME="dsearch-${{ matrix.goos }}-${{ matrix.goarch }}"
sha256sum "${BINARY_NAME}.gz" > "${BINARY_NAME}.gz.sha256"
sha256sum "${BINARY_NAME}.tar.gz" > "${BINARY_NAME}.tar.gz.sha256"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dsearch-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
dsearch-${{ matrix.goos }}-${{ matrix.goarch }}.gz
dsearch-${{ matrix.goos }}-${{ matrix.goarch }}.gz.sha256
dsearch-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
dsearch-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz.sha256
create_release:
name: 📦 Create GitHub Release
runs-on: ubuntu-24.04
needs: [build]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Generate Changelog
id: changelog
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
echo "No previous tag found, using all commits"
CHANGELOG=$(git log --oneline --pretty=format:"- %s (%h)" | head -50)
else
echo "Generating changelog from $PREVIOUS_TAG to HEAD"
CHANGELOG=$(git log --oneline --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD)
fi
cat > CHANGELOG.md << EOF
## What's Changed
$CHANGELOG
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG}...${{ github.ref_name }}
EOF
echo "changelog<<EOF" >> $GITHUB_OUTPUT
cat CHANGELOG.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: comnoco/create-release-action@v2.0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
- name: Upload assets
run: |
VERSION=${{ github.ref_name }}
find ./artifacts -name "dsearch-*" -type f | while read file; do
gh release upload "$VERSION" "$file" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}