Skip to content

Update go.yml

Update go.yml #6

Workflow file for this run

# This workflow will build a Golang project, create a release, and build artifacts for multiple OS platforms
name: Go
on:
push:
tags:
- '*' # Trigger for any tag
pull_request:
branches:
- 'main'
permissions:
contents: write # Grant write permissions to the contents
jobs:
build:
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
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Build for ${{ matrix.os }}
run: go build -o tradingview-to-ibkr-${{ matrix.goos }}-${{ matrix.goarch }} -tags netgo
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
- name: Archive build artifacts
id: archive
uses: actions/upload-artifact@v3
with:
name: tradingview-to-ibkr-${{ matrix.goos }}-${{ matrix.goarch }}
path: tradingview-to-ibkr-${{ matrix.goos }}-${{ matrix.goarch }}
create_release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: tradingview-to-ibkr-linux-amd64
path: ./build/linux64
- name: Download Windows artifact
uses: actions/download-artifact@v3
with:
name: tradingview-to-ibkr-windows-amd64
path: ./build/win64
- name: Download macOS artifact
uses: actions/download-artifact@v3
with:
name: tradingview-to-ibkr-darwin-arm64
path: ./build/mac64
- name: Extract tag name
id: extract_tag
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
release_name: Release ${{ env.TAG_NAME }}
body: |
Changes in this release:
- List your changes here
draft: false
prerelease: false
- name: Upload Release Asset (Linux)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/linux64/tradingview-to-ibkr-linux-amd64
asset_name: tradingview-to-ibkr-linux64
asset_content_type: application/octet-stream
- name: Upload Release Asset (Windows)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/win64/tradingview-to-ibkr-windows-amd64
asset_name: tradingview-to-ibkr-win64
asset_content_type: application/octet-stream
- name: Upload Release Asset (macOS)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/mac64/tradingview-to-ibkr-darwin-arm64
asset_name: tradingview-to-ibkr-macos-arm64
asset_content_type: application/octet-stream