-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
138 additions
and
0 deletions.
There are no files selected for viewing
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
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 |