Skip to content

fix(gha): update ci worflow #44

fix(gha): update ci worflow

fix(gha): update ci worflow #44

Workflow file for this run

name: CI/CD Pipeline
on:
push:
paths:
- '**.go'
tags:
- 'v*.*.*' # Triggers the workflow on version tags (e.g., v1.0.0)
pull_request:
paths:
- '**.go'
- '.github/workflows/**'
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v3
# TODO: Move this to a separate re-usable action
- name: Cache Skaffold
id: cache-skaffold
uses: actions/cache@v4
with:
path: |
/usr/local/bin/skaffold
key: skaffold-${{ runner.os }}-${{ hashFiles('**/skaffold.yaml') }}
- name: Install Skaffold
if: steps.cache-skaffold.outputs.cache-hit != 'true'
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
chmod +x skaffold
sudo mv skaffold /usr/local/bin
- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
go-version: '1.21' # Specify your Go version
- name: Build binary
run: |
mkdir -p dist
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/kickstart-${{ matrix.goos }}-${{ matrix.goarch }} main.go
- name: Run tests
run: make test
- name: Upload build artifacts
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v3
with:
name: kickstart-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/kickstart-${{ matrix.goos }}-${{ matrix.goarch }}
release:
name: Create Release and Upload Assets
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Linux AMD64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-linux-amd64
- name: Download Linux ARM64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-linux-arm64
- name: Download Darwin AMD64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-darwin-amd64
- name: Download Darwin ARM64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-darwin-arm64
- name: Download Windows AMD64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-windows-amd64
- name: Download Windows ARM64 Artifact
uses: actions/download-artifact@v3
with:
name: kickstart-windows-arm64
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload Linux AMD64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-linux-amd64
asset_name: kickstart-linux-amd64
asset_content_type: application/octet-stream
- name: Upload Linux ARM64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-linux-arm64
asset_name: kickstart-linux-arm64
asset_content_type: application/octet-stream
- name: Upload Darwin AMD64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-darwin-amd64
asset_name: kickstart-darwin-amd64
asset_content_type: application/octet-stream
- name: Upload Darwin ARM64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-darwin-arm64
asset_name: kickstart-darwin-arm64
asset_content_type: application/octet-stream
- name: Upload Windows AMD64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-windows-amd64.exe
asset_name: kickstart-windows-amd64.exe
asset_content_type: application/octet-stream
- name: Upload Windows ARM64 Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kickstart-windows-arm64.exe
asset_name: kickstart-windows-arm64.exe
asset_content_type: application/octet-stream