create codecov.yaml #10
This file contains 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: | |
branches: | |
- main | |
- develop | |
# on: | |
# push: | |
# tags: | |
# - 'v*.*.*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: [1.23] | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Install dependencies | |
run: go mod tidy | |
- name: Build binary | |
run: | | |
mkdir -p dist | |
case ${{ matrix.os }} in | |
ubuntu-latest) GOOS=linux ;; | |
windows-latest) GOOS=windows ;; | |
macos-latest) GOOS=darwin ;; | |
esac | |
GOARCH=amd64 | |
OUTPUT_NAME=gCommit | |
if [ "$GOOS" = "windows" ]; then OUTPUT_NAME=gCommit.exe; fi | |
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-w -s" -o dist/$OUTPUT_NAME ./cmd/main.go | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-binary | |
path: dist/ | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: ubuntu-latest-binary | |
path: dist/ubuntu | |
- uses: actions/download-artifact@v4 | |
with: | |
name: windows-latest-binary | |
path: dist/windows | |
- uses: actions/download-artifact@v4 | |
with: | |
name: macos-latest-binary | |
path: dist/macos | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.run_number }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset (Ubuntu) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: dist/ubuntu/gCommit | |
asset_name: gCommit-ubuntu | |
asset_content_type: application/octet-stream | |
- name: Upload Release Asset (Windows) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: dist/windows/gCommit.exe | |
asset_name: gCommit-windows.exe | |
asset_content_type: application/octet-stream | |
- name: Upload Release Asset (macOS) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: dist/macos/gCommit | |
asset_name: gCommit-macos | |
asset_content_type: application/octet-stream |