2023-09-13 02:18:31 -04:00
|
|
|
# This workflow will build a golang project
|
|
|
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
|
|
|
|
|
|
|
|
name: Go
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- '*'
|
2023-09-14 05:59:17 -04:00
|
|
|
workflow_dispatch:
|
|
|
|
|
2023-09-13 02:18:31 -04:00
|
|
|
jobs:
|
|
|
|
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-14 05:59:17 -04:00
|
|
|
- uses: actions/checkout@v3
|
2023-09-13 02:18:31 -04:00
|
|
|
|
2023-09-14 05:59:17 -04:00
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v4
|
|
|
|
with:
|
|
|
|
go-version: '1.21'
|
2023-09-13 02:18:31 -04:00
|
|
|
|
2023-09-14 05:59:17 -04:00
|
|
|
- name: Build
|
|
|
|
run: |
|
2023-09-20 21:08:02 -04:00
|
|
|
LDFLAGS="-s -w -X config.Version=${{ github.ref_name }}"
|
2023-09-14 05:59:17 -04:00
|
|
|
|
2023-09-13 02:18:31 -04:00
|
|
|
# Linux
|
2023-09-13 03:15:46 -04:00
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o output/sub2clash-linux-amd64 main.go
|
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$LDFLAGS" -o output/sub2clash-linux-arm64 main.go
|
2023-09-14 05:59:17 -04:00
|
|
|
|
2023-09-13 02:18:31 -04:00
|
|
|
# Darwin
|
2023-09-13 03:15:46 -04:00
|
|
|
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -o output/sub2clash-darwin-amd64 main.go
|
2023-09-14 05:59:17 -04:00
|
|
|
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="$LDFLAGS" -o output/sub2clash-darwin-arm64 main.go
|
|
|
|
|
2023-09-13 02:18:31 -04:00
|
|
|
# Windows
|
2023-09-13 03:15:46 -04:00
|
|
|
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -o output/sub2clash-windows-amd64.exe main.go
|
2023-09-14 05:59:17 -04:00
|
|
|
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags="$LDFLAGS" -o output/sub2clash-windows-arm64.exe main.go
|
|
|
|
|
|
|
|
- name: Create Release
|
|
|
|
id: create_release
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
tag_name: ${{ github.ref_name }}
|
|
|
|
release_name: Release ${{ github.ref_name }}
|
|
|
|
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: ./output/sub2clash-linux-amd64
|
|
|
|
asset_name: sub2clash-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: ./output/sub2clash-linux-arm64
|
|
|
|
asset_name: sub2clash-linux-arm64
|
|
|
|
asset_content_type: application/octet-stream
|
|
|
|
|
|
|
|
- name: Upload Release Asset (Darwin amd64)
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
|
|
asset_path: ./output/sub2clash-darwin-amd64
|
|
|
|
asset_name: sub2clash-darwin-amd64
|
|
|
|
asset_content_type: application/octet-stream
|
|
|
|
|
|
|
|
- name: Upload Release Asset (Darwin arm64)
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
|
|
asset_path: ./output/sub2clash-darwin-arm64
|
|
|
|
asset_name: sub2clash-darwin-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: ./output/sub2clash-windows-amd64.exe
|
|
|
|
asset_name: sub2clash-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:
|
2023-09-14 22:47:23 -04:00
|
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
2023-09-14 05:59:17 -04:00
|
|
|
asset_path: ./output/sub2clash-windows-arm64.exe
|
|
|
|
asset_name: sub2clash-windows-arm64.exe
|
|
|
|
asset_content_type: application/octet-stream
|
2023-09-13 02:18:31 -04:00
|
|
|
|