Skip to content

Commit

Permalink
Update go.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
FelikZ authored Aug 5, 2024
1 parent be1d7e5 commit d14154a
Showing 1 changed file with 62 additions and 28 deletions.
90 changes: 62 additions & 28 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,8 @@ permissions:
contents: write # Grant write permissions to the contents

jobs:
build:
build_linux:
runs-on: ubuntu-latest
outputs:
windows-artifact: ${{ steps.windows-artifact.outputs.artifact }}
linux-artifact: ${{ steps.linux-artifact.outputs.artifact }}
macos-artifact: ${{ steps.macos-artifact.outputs.artifact }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
goos: [linux, windows, darwin]
goarch: [amd64, amd64, arm64]
steps:
- uses: actions/checkout@v4

Expand All @@ -33,42 +24,85 @@ jobs:
with:
go-version: '1.22'

- name: Build for ${{ matrix.os }}
run: go build -o tradingview-to-ibkr-${{ matrix.goos }}-${{ matrix.goarch }} -tags netgo
- name: Build for Linux
run: go build -o tradingview-to-ibkr-linux64
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOOS: linux
GOARCH: amd64

- name: Archive build artifacts
id: archive
- name: Archive Linux build artifact
uses: actions/upload-artifact@v3
with:
name: tradingview-to-ibkr-${{ matrix.goos }}-${{ matrix.goarch }}
path: tradingview-to-ibkr-${{ matrix.goos }}-${{ matrix.goarch }}
name: tradingview-to-ibkr-linux64
path: tradingview-to-ibkr-linux64

build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

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

- name: Build for Windows
run: go build -o tradingview-to-ibkr-win64.exe
env:
GOOS: windows
GOARCH: amd64

- name: Archive Windows build artifact
uses: actions/upload-artifact@v3
with:
name: tradingview-to-ibkr-win64
path: tradingview-to-ibkr-win64.exe

build_macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

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

- name: Build for macOS
run: go build -o tradingview-to-ibkr-macos-arm64
env:
GOOS: darwin
GOARCH: arm64

- name: Archive macOS build artifact
uses: actions/upload-artifact@v3
with:
name: tradingview-to-ibkr-macos-arm64
path: tradingview-to-ibkr-macos-arm64

create_release:
runs-on: ubuntu-latest
needs: build
needs: [build_linux, build_windows, build_macos]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4

- name: Download build artifacts
- name: Download Linux build artifact
uses: actions/download-artifact@v3
with:
name: tradingview-to-ibkr-linux-amd64
name: tradingview-to-ibkr-linux64
path: ./build/linux64

- name: Download Windows artifact
- name: Download Windows build artifact
uses: actions/download-artifact@v3
with:
name: tradingview-to-ibkr-windows-amd64
name: tradingview-to-ibkr-win64
path: ./build/win64

- name: Download macOS artifact
- name: Download macOS build artifact
uses: actions/download-artifact@v3
with:
name: tradingview-to-ibkr-darwin-arm64
name: tradingview-to-ibkr-macos-arm64
path: ./build/mac64

- name: Extract tag name
Expand All @@ -95,7 +129,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/linux64/tradingview-to-ibkr-linux-amd64
asset_path: ./build/linux64/tradingview-to-ibkr-linux64
asset_name: tradingview-to-ibkr-linux64
asset_content_type: application/octet-stream

Expand All @@ -105,7 +139,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/win64/tradingview-to-ibkr-windows-amd64
asset_path: ./build/win64/tradingview-to-ibkr-win64.exe
asset_name: tradingview-to-ibkr-win64
asset_content_type: application/octet-stream

Expand All @@ -115,6 +149,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/mac64/tradingview-to-ibkr-darwin-arm64
asset_path: ./build/mac64/tradingview-to-ibkr-macos-arm64
asset_name: tradingview-to-ibkr-macos-arm64
asset_content_type: application/octet-stream

0 comments on commit d14154a

Please sign in to comment.