From b4d17a01f986e3aa15d73f1eac4155f01bc891db Mon Sep 17 00:00:00 2001 From: database64128 Date: Sun, 10 Jan 2021 23:06:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=99=20GitHub=20Actions:=20build,=20tes?= =?UTF-8?q?t,=20publish,=20release,=20upload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 54 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..bca8668d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,54 @@ +name: Build + +on: + push: + branches-ignore: + - 'v4' + - 'rm' + paths-ignore: + - 'README.md' + - 'LICENSE' + pull_request: + branches-ignore: + - 'v4' + - 'rm' + paths-ignore: + - 'README.md' + - 'LICENSE' + +jobs: + build: + name: Build + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal + # Publish + - name: Publish framework-dependent + run: dotnet publish Shadowsocks.WPF -c Release --no-restore + # - name: Publish self-contained for Windows ARM64 + # run: dotnet publish Shadowsocks.WPF -c Release -p:PublishTrimmed=true -r win-arm64 --self-contained + - name: Publish self-contained for Windows x64 + run: dotnet publish Shadowsocks.WPF -c Release -p:PublishTrimmed=true -r win-x64 --self-contained + # Upload + # - name: Upload artifacts for Windows ARM64 + # uses: actions/upload-artifact@v2 + # with: + # name: shadowsocks-wpf-${{ github.sha }}-windows-arm64 + # path: Shadowsocks.WPF/bin/Release/net5.0-windows10.0.19041.0/win-arm64/publish/ + - name: Upload artifacts for Windows x64 + uses: actions/upload-artifact@v2 + with: + name: shadowsocks-wpf-${{ github.sha }}-windows-x64 + path: Shadowsocks.WPF/bin/Release/net5.0-windows10.0.19041.0/win-x64/publish/ + - name: Upload artifacts for Windows framework-dependent + uses: actions/upload-artifact@v2 + with: + name: shadowsocks-wpf-${{ github.sha }}-windows + path: Shadowsocks.WPF/bin/Release/net5.0-windows10.0.19041.0/publish/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..b381c67e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + publish_upload: + name: Publish and upload + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal + # Publish + - name: Publish framework-dependent + run: dotnet publish Shadowsocks.WPF -c Release --no-restore + # - name: Publish self-contained for Windows ARM64 + # run: dotnet publish Shadowsocks.WPF -c Release -p:PublishTrimmed=true -r win-arm64 --self-contained + - name: Publish self-contained for Windows x64 + run: dotnet publish Shadowsocks.WPF -c Release -p:PublishTrimmed=true -r win-x64 --self-contained + # Get version + - name: Get version + id: get_version + shell: bash + run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + # Package + - name: Package for Windows + run: | + cd Shadowsocks.WPF/bin/Release/net5.0-windows10.0.19041.0/publish + 7z a -tzip -mx=9 -mfb=128 ../shadowsocks-wpf-${{ steps.get_version.outputs.VERSION }}-windows.zip . + 7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=64m -ms=on ../shadowsocks-wpf-${{ steps.get_version.outputs.VERSION }}-windows.7z . + # cd ../win-arm64/publish + # 7z a -tzip -mx=9 -mfb=128 ../../shadowsocks-wpf-${{ steps.get_version.outputs.VERSION }}-windows-arm64.zip . + # 7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=64m -ms=on ../../shadowsocks-wpf-${{ steps.get_version.outputs.VERSION }}-windows-arm64.7z . + cd ../../win-x64/publish + 7z a -tzip -mx=9 -mfb=128 ../../shadowsocks-wpf-${{ steps.get_version.outputs.VERSION }}-windows-x64.zip . + 7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=64m -ms=on ../../shadowsocks-wpf-${{ steps.get_version.outputs.VERSION }}-windows-x64.7z . + # Release + - name: Upload release assets for Windows + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: Shadowsocks.WPF/bin/Release/net5.0-windows10.0.19041.0/shadowsocks-wpf-* + tag: ${{ github.ref }} + file_glob: true + prerelease: true