Chore: add build windows actions
This commit is contained in:
parent
d74dd69329
commit
0321ddbb90
75
.github/workflows/build-windows-amd.yml
vendored
Normal file
75
.github/workflows/build-windows-amd.yml
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
name: Build-Windows
|
||||
on: [push]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Go cache paths
|
||||
id: go-cache-paths
|
||||
run: |
|
||||
echo "::set-output name=go-build::$(go env GOCACHE)"
|
||||
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
|
||||
|
||||
- name: Cache go module
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
${{ steps.go-cache-paths.outputs.go-mod }}
|
||||
${{ steps.go-cache-paths.outputs.go-build }}
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: '3.9'
|
||||
architecture: 'x64'
|
||||
|
||||
- name: Get dependencies, run test
|
||||
id: test
|
||||
run: |
|
||||
cmd /c mklink /J D:\python-amd64 $env:pythonLocation
|
||||
|
||||
echo "::set-output name=file_sha::$(git describe --tags --always)"
|
||||
echo "::set-output name=file_date::$(Get-Date -Format 'yyyyMMdd')"
|
||||
|
||||
((Get-Content -path constant/version.go -Raw) -replace 'unknown version',$(git describe --tags --always)) | Set-Content -Path constant/version.go
|
||||
((Get-Content -path constant/version.go -Raw) -replace 'unknown time',$(Get-Date)) | Set-Content -Path constant/version.go
|
||||
|
||||
# go test
|
||||
go test -tags build_actions ./...
|
||||
|
||||
- name: Build
|
||||
#if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
$env:CGO_ENABLED=1; go build -tags build_actions -trimpath -ldflags '-w -s -buildid=' -o bin/clash-windows-amd64.exe
|
||||
$env:GOAMD64="v3"; $env:CGO_ENABLED=1; go build -tags build_actions -trimpath -ldflags '-w -s -buildid=' -o bin/clash-windows-amd64-v3.exe
|
||||
|
||||
cd bin/
|
||||
Compress-Archive -Path clash-windows-amd64.exe -DestinationPath clash-windows-amd64-$(git describe --tags --always)-$(Get-Date -Format 'yyyyMMdd').zip
|
||||
Compress-Archive -Path clash-windows-amd64-v3.exe -DestinationPath clash-windows-amd64-v3-$(git describe --tags --always)-$(Get-Date -Format 'yyyyMMdd').zip
|
||||
Remove-Item -Force clash-windows-amd64.exe
|
||||
Remove-Item -Force clash-windows-amd64-v3.exe
|
||||
|
||||
- name: Upload files to Artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
if: startsWith(github.ref, 'refs/tags/') == false
|
||||
with:
|
||||
name: clash-windows-amd64-${{ steps.test.outputs.file_sha }}-${{ steps.test.outputs.file_date }}
|
||||
path: |
|
||||
bin/*
|
||||
|
||||
- name: Delete workflow runs
|
||||
uses: GitRML/delete-workflow-runs@main
|
||||
with:
|
||||
retain_days: 1
|
||||
keep_minimum_runs: 2
|
11
.github/workflows/release.yml
vendored
11
.github/workflows/release.yml
vendored
@ -1,5 +1,8 @@
|
||||
name: Release
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- rm
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
@ -59,12 +62,6 @@ jobs:
|
||||
docker pull techknowlogick/xgo:latest
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
|
||||
- name: SSH connection to Actions
|
||||
uses: P3TERX/ssh2actions@v1.0.0
|
||||
if: github.actor == github.repository_owner && contains(github.event.head_commit.message, '[ssh]')
|
||||
env:
|
||||
SSH_PASSWORD: ${{ secrets.ADAWADLHIOH }}
|
||||
|
||||
- name: Build
|
||||
#if: startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
|
10
component/script/build_actions.go
Normal file
10
component/script/build_actions.go
Normal file
@ -0,0 +1,10 @@
|
||||
//go:build build_actions
|
||||
|
||||
package script
|
||||
|
||||
/*
|
||||
#cgo windows,amd64 CFLAGS: -ID:/python-amd64/include -DMS_WIN64
|
||||
|
||||
#cgo windows,amd64 LDFLAGS: -LD:/python-amd64/libs -lpython39 -lpthread -lm
|
||||
*/
|
||||
import "C"
|
Reference in New Issue
Block a user