From 62ebc6625918f7fc5d96d608aaefc010fe54b906 Mon Sep 17 00:00:00 2001 From: ljw <84855512@qq.com> Date: Thu, 26 Sep 2024 11:46:17 +0800 Subject: [PATCH] test release_arm64.yml --- .github/workflows/release_arm64.yml | 84 +++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/release_arm64.yml diff --git a/.github/workflows/release_arm64.yml b/.github/workflows/release_arm64.yml new file mode 100644 index 0000000..ac15190 --- /dev/null +++ b/.github/workflows/release_arm64.yml @@ -0,0 +1,84 @@ +name: Build and Release + +#on: +# push: +# tags: +# - 'v*.*.*' # 当推送带有版本号的 tag(例如 v1.0.0)时触发工作流 +on: + push: + branches: [ "master" ] +# pull_request: +# branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + goos: [ linux ] # 指定要构建的操作系统 + goarch: [ arm64 ] # 指定架构 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go environment + uses: actions/setup-go@v4 + with: + go-version: '1.22' # 选择 Go 版本 + + - name: Set up npm + uses: actions/setup-node@v2 + with: + node-version: '20' + + - name: install gcc zip musl + run: | + sudo apt-get install gcc-aarch64-linux-gnu -y + + + - name: build rustdesk-api-web + run: | + git clone https://github.com/lejianwen/rustdesk-api-web + cd rustdesk-api-web + npm install + npm run build + mkdir ../resources/admin/ -p + cp -ar dist/* ../resources/admin/ + + - name: tidy + run: go mod tidy + + + - name: swag + run: | + go install github.com/swaggo/swag/cmd/swag@latest + swag init -g cmd/apimain.go --output docs/api --instanceName api --exclude http/controller/admin + swag init -g cmd/apimain.go --output docs/admin --instanceName admin --exclude http/controller/api + + - name: Build for ${{ matrix.goos }}-${{ matrix.goarch }} + run: | + mkdir release -p + cp -ar resources release/ + cp -ar docs release/ + cp -ar conf release/ + mkdir -p release/data + mkdir -p release/runtime + GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CC=aarch64-linux-gnu-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go + tar -czf ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz ./release + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: myapp-${{ matrix.goos }}-${{ matrix.goarch }} + path: | + ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz + + - name: Upload to GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: | + ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}