Skip to content

Merge pull request #9 from whalechoi/master #199

Merge pull request #9 from whalechoi/master

Merge pull request #9 from whalechoi/master #199

Workflow file for this run

name: Build
on:
workflow_dispatch:
push:
branches:
- master
paths:
- "**/*.go"
- "go.mod"
- ".github/workflows/*.yml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
- "go.mod"
- ".github/workflows/*.yml"
jobs:
build:
permissions:
contents: write
strategy:
matrix:
include:
- goos: android
goarch: arm64
cc: aarch64-linux-android34-clang
cxx: aarch64-linux-android34-clang++
- goos: android
goarch: amd64
cc: x86_64-linux-android34-clang
cxx: x86_64-linux-android34-clang++
fail-fast: false
runs-on: ubuntu-latest
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 1
steps:
- name: Checkout codebase
uses: actions/checkout@v4
- name: Set up NDK
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
ndk-version: r26c
- name: Show workflow information
run: |
export _NAME=$(jq ".[\"$GOOS-$GOARCH\"].friendlyName" -r < .github/build/friendly-filenames.json)
export _CC=${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.cc }}
export _CXX=${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.cxx }}
echo "GOOS: $GOOS, GOARCH: $GOARCH, CC: $_CC, CXX: $_CXX, RELEASE_NAME: $_NAME"
echo "CC=$_CC" >> $GITHUB_ENV
echo "CXX=$_CXX" >> $GITHUB_ENV
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
check-latest: true
- name: Get project dependencies
run: go get ./main
- name: Build XrayHelper
run: |
mkdir -p build_assets
go build -v -o build_assets/xrayhelper -trimpath -ldflags "-s -w -buildid=" ./main
- name: Copy Files
run: |
cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
cp ${GITHUB_WORKSPACE}/README_zh_CN.md ./build_assets/README_zh_CN.md
cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
cp ${GITHUB_WORKSPACE}/config.yml ./build_assets/config.yml
- name: Create ZIP archive
shell: bash
run: |
pushd build_assets || exit 1
touch -mt $(date +%Y01010000) *
zip -9vr ../XrayHelper-${{ env.ASSET_NAME }}.zip .
popd || exit 1
FILE=./XrayHelper-${{ env.ASSET_NAME }}.zip
DGST=$FILE.dgst
for METHOD in {"md5","sha1","sha256","sha512"}
do
openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST
done
- name: Change the name
run: |
mv build_assets XrayHelper-${{ env.ASSET_NAME }}
- name: Upload files to Artifacts
uses: actions/upload-artifact@v4
with:
name: XrayHelper-${{ env.ASSET_NAME }}
path: |
./XrayHelper-${{ env.ASSET_NAME }}/*