Update go.yml #25
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: Go | |
on: | |
push: | |
branches: ["main"] | |
paths-ignore: | |
- README.md | |
- .gitignore | |
#- .github/** | |
- LICENSE | |
jobs: | |
gettime: | |
runs-on: ubuntu-latest | |
outputs: | |
timestamp: ${{ env.TIMESTAMP }} | |
steps: | |
- name: Get current timestamp | |
id: timestamp | |
run: echo "TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | |
build: | |
runs-on: ubuntu-latest | |
needs: gettime | |
strategy: | |
matrix: | |
os: [linux, windows, darwin] | |
go-version: ["1.23.1"] | |
env: | |
TIMESTAMP: ${{ needs.gettime.outputs.timestamp }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Build | |
run: | | |
mkdir -p bin | |
case ${{ matrix.os }} in | |
linux) | |
GOOS=linux GOARCH=amd64 make BINARY_NAME=kthcloud_amd64_linux BUILDTIMESTAMP=${{ env.TIMESTAMP }} ;; | |
windows) | |
GOOS=windows GOARCH=amd64 make BINARY_NAME=kthcloud_amd64_windows.exe BUILDTIMESTAMP=${{ env.TIMESTAMP }} ;; | |
darwin) | |
GOOS=darwin GOARCH=arm64 make BINARY_NAME=kthcloud_arm64_macos BUILDTIMESTAMP=${{ env.TIMESTAMP }} ;; | |
esac | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-binaries | |
path: bin/* | |
if-no-files-found: error | |
release: | |
needs: | |
- gettime | |
- build | |
runs-on: ubuntu-latest | |
env: | |
TIMESTAMP: ${{ needs.gettime.outputs.timestamp }} | |
outputs: | |
upload_url: ${{ steps.step_upload_url.outputs.upload_url }} | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: "./artifacts" | |
if-no-files-found: error | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
with: | |
tag_name: release-${{ env.TIMESTAMP }} | |
release_name: Release ${{ env.TIMESTAMP }} | |
body: Latest release build by github actions | |
files: artifacts/**/* | |
- id: step_upload_url | |
run: echo "::set-output name=upload_url::${{ steps.create_release.outputs.upload_url }}" |