Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gha): update ci worflow #10

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 105 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ on:
push:
paths:
- '**.go'
tags:
- 'v*.*.*' # Triggers the workflow on version tags (e.g., v1.0.0)

pull_request:
paths:
- '**.go'
- '.github/workflows/**'


release:
types: [created]

jobs:
build:
Expand Down Expand Up @@ -43,7 +42,6 @@ jobs:
chmod +x skaffold
sudo mv skaffold /usr/local/bin


- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
Expand All @@ -57,28 +55,120 @@ jobs:
- name: Run tests
run: make test

- name: Upload artifact (only for release)
if: github.event_name == 'release'
uses: actions/upload-artifact@v4.3.6
- 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 GitHub Release
name: Create Release and Upload Assets
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release'
if: startsWith(github.ref, 'refs/tags/v')

steps:
- name: Download artifacts
uses: actions/download-artifact@v4.1.8
- 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:
path: dist
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
uses: softprops/action-gh-release@v2.0.8
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: dist/*
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
Loading