name: Publich
'on':
  push:
    branches:
      - master
jobs:
  build:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v3
      - name: setup node.js
        uses: actions/setup-node@v2
        with:
          node-version: '16'
      - name: setup dotnet8
        uses: actions/setup-dotnet@v2
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          dotnet-version: 8.0.x
      - name: setup msbuild
        uses: microsoft/setup-msbuild@v2
        with:
          msbuild-architecture: x64
      - name: install dotnet maui
        run: dotnet workload install maui
      - name: get current date
        id: date
        run: echo "::set-output name=today::$(date +'%Y-%m-%d')"
      - name: create release
        id: create_release
        uses: GongT/actions-recreate-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          tag_name: v1.8.3
          release_name: v1.8.3.${{ steps.date.outputs.today }}
          draft: false
          prerelease: false
          body: "1. 一些累计更新\r\n2. 修复socks5，解决CPU爆满问题，增加域名解析和HTTP代理\r\n3. 优化唤醒模块\r\n5. 管理端口改为1804，一个端口托管Web+Websocket"
      - name: publish projects
        run: ./publish.bat "C:\\Android\\android-sdk"
      - name: upload-win-x86-oss
        id: upload-win-x86-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker-win-x86.zip
          target-path: /downloads/linker/v1.8.3/linker-win-x86.zip
      - name: upload-win-x86
        id: upload-win-x86
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker-win-x86.zip
          asset_name: linker-win-x86.zip
          asset_content_type: application/zip
      - name: upload-win-x64-oss
        id: upload-win-x64-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker-win-x64.zip
          target-path: /downloads/linker/v1.8.3/linker-win-x64.zip
      - name: upload-win-x64
        id: upload-win-x64
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker-win-x64.zip
          asset_name: linker-win-x64.zip
          asset_content_type: application/zip
      - name: upload-win-arm64-oss
        id: upload-win-arm64-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker-win-arm64.zip
          target-path: /downloads/linker/v1.8.3/linker-win-arm64.zip
      - name: upload-win-arm64
        id: upload-win-arm64
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker-win-arm64.zip
          asset_name: linker-win-arm64.zip
          asset_content_type: application/zip
      - name: upload-linux-x64-oss
        id: upload-linux-x64-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker-linux-x64.zip
          target-path: /downloads/linker/v1.8.3/linker-linux-x64.zip
      - name: upload-linux-x64
        id: upload-linux-x64
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker-linux-x64.zip
          asset_name: linker-linux-x64.zip
          asset_content_type: application/zip
      - name: upload-linux-arm-oss
        id: upload-linux-arm-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker-linux-arm.zip
          target-path: /downloads/linker/v1.8.3/linker-linux-arm.zip
      - name: upload-linux-arm
        id: upload-linux-arm
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker-linux-arm.zip
          asset_name: linker-linux-arm.zip
          asset_content_type: application/zip
      - name: upload-linux-arm64-oss
        id: upload-linux-arm64-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker-linux-arm64.zip
          target-path: /downloads/linker/v1.8.3/linker-linux-arm64.zip
      - name: upload-linux-arm64
        id: upload-linux-arm64
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker-linux-arm64.zip
          asset_name: linker-linux-arm64.zip
          asset_content_type: application/zip
      - name: upload-linux-musl-x64-oss
        id: upload-linux-musl-x64-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker-linux-musl-x64.zip
          target-path: /downloads/linker/v1.8.3/linker-linux-musl-x64.zip
      - name: upload-linux-musl-x64
        id: upload-linux-musl-x64
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker-linux-musl-x64.zip
          asset_name: linker-linux-musl-x64.zip
          asset_content_type: application/zip
      - name: upload-linux-musl-arm-oss
        id: upload-linux-musl-arm-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker-linux-musl-arm.zip
          target-path: /downloads/linker/v1.8.3/linker-linux-musl-arm.zip
      - name: upload-linux-musl-arm
        id: upload-linux-musl-arm
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker-linux-musl-arm.zip
          asset_name: linker-linux-musl-arm.zip
          asset_content_type: application/zip
      - name: upload-linux-musl-arm64-oss
        id: upload-linux-musl-arm64-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker-linux-musl-arm64.zip
          target-path: /downloads/linker/v1.8.3/linker-linux-musl-arm64.zip
      - name: upload-linux-musl-arm64
        id: upload-linux-musl-arm64
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker-linux-musl-arm64.zip
          asset_name: linker-linux-musl-arm64.zip
          asset_content_type: application/zip
      - name: upload-version-oss
        id: upload-version-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/version.txt
          target-path: /downloads/linker/version.txt
      - name: upload-install-service-oss
        id: upload-install-service-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./src/linker/linker.service
          target-path: /downloads/linker/linker.service
      - name: upload-install-oss
        id: upload-install-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./src/linker/linker-install.sh
          target-path: /downloads/linker/linker-install.sh
      - name: upload-apk-oss
        id: upload-apk-oss
        uses: tvrcgo/oss-action@v0.1.1
        with:
          region: oss-cn-shenzhen
          key-id: ${{ secrets.ALIYUN_OSS_ID }}
          key-secret: ${{ secrets.ALIYUN_OSS_SECRET }}
          bucket: ide-qbcode
          asset-path: ./public/publish-zip/linker.apk
          target-path: /downloads/linker/v1.8.3/linker.apk
      - name: upload-apk
        id: upload-apk
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./public/publish-zip/linker.apk
          asset_name: linker.apk
          asset_content_type: application/apk
