Skip to content

Commit

Permalink
Create go-build-release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
iuu6 committed Aug 6, 2024
1 parent e40e7b7 commit 92c69eb
Showing 1 changed file with 138 additions and 0 deletions.
138 changes: 138 additions & 0 deletions .github/workflows/go-build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Go Build and Release

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

strategy:
matrix:
go-version: [1.22.4]
os: [ubuntu-latest, windows-latest, macos-latest]
arch: [amd64, arm64]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Install dependencies
run: go mod tidy

- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o AIOPrivacyBot-${{ matrix.os }}-${{ matrix.arch }}

- name: Run tests
run: go test ./...

release:
name: Create Release
runs-on: ubuntu-latest
needs: build

if: github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22.4

- name: Install dependencies
run: go mod tidy

- name: Build for all platforms
run: |
GOOS=linux GOARCH=amd64 go build -o AIOPrivacyBot-linux-amd64
GOOS=linux GOARCH=arm64 go build -o AIOPrivacyBot-linux-arm64
GOOS=windows GOARCH=amd64 go build -o AIOPrivacyBot-windows-amd64.exe
GOOS=windows GOARCH=arm64 go build -o AIOPrivacyBot-windows-arm64.exe
GOOS=darwin GOARCH=amd64 go build -o AIOPrivacyBot-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -o AIOPrivacyBot-darwin-arm64
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v1.0.${{ github.run_number }}
release_name: Release v1.0.${{ github.run_number }}
body: |
Changes in this release:
${{ github.event.head_commit.message }}
draft: false
prerelease: false

- name: Upload Release Asset Linux AMD64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AIOPrivacyBot-linux-amd64
asset_name: AIOPrivacyBot-linux-amd64
asset_content_type: application/octet-stream

- name: Upload Release Asset Linux ARM64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AIOPrivacyBot-linux-arm64
asset_name: AIOPrivacyBot-linux-arm64
asset_content_type: application/octet-stream

- name: Upload Release Asset Windows AMD64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AIOPrivacyBot-windows-amd64.exe
asset_name: AIOPrivacyBot-windows-amd64.exe
asset_content_type: application/octet-stream

- name: Upload Release Asset Windows ARM64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AIOPrivacyBot-windows-arm64.exe
asset_name: AIOPrivacyBot-windows-arm64.exe
asset_content_type: application/octet-stream

- name: Upload Release Asset macOS AMD64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AIOPrivacyBot-darwin-amd64
asset_name: AIOPrivacyBot-darwin-amd64
asset_content_type: application/octet-stream

- name: Upload Release Asset macOS ARM64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AIOPrivacyBot-darwin-arm64
asset_name: AIOPrivacyBot-darwin-arm64
asset_content_type: application/octet-stream

0 comments on commit 92c69eb

Please sign in to comment.