From e0a0002ca1c2362cb98f6e41e085918679487170 Mon Sep 17 00:00:00 2001 From: ppc Date: Tue, 3 Sep 2024 14:03:40 +0100 Subject: [PATCH] add server/website build script --- .github/workflows/release.yml | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fbd069c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +name: Release + +on: + push: + tags: + - '^v?(?:[0-9]+.?){1,4}$' + workflow_dispatch: + inputs: + tag: + description: 'Tag Name' + required: true + +jobs: + get-upload-url: + runs-on: ubuntu-latest + name: Get Asset Upload URL + + outputs: + upload_url: ${{ steps.get-url.outputs.url }} + + env: + TAG: ${{ github.event.inputs.tag || github.ref_name }} + + steps: + - name: Get Upload URL + id: get-url + run: | + UPLOAD_URL=$(curl -s -X GET -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" "https://gitea.tendokyu.moe/api/v1/repos/ppc/amnet/releases/tags/$TAG" | jq -r '.upload_url') + echo "url=$UPLOAD_URL" >> $GITHUB_ENV + + build-server: + runs-on: windows-latest + needs: get-upload-url + name: Build amnet-server + + env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + + - name: Set version + run: | + $tag="${{ github.event.inputs.tag || github.ref_name }}".TrimStart("v") + echo "VERSION=$tag" >> $env:GITHUB_ENV + + - name: Publish + run: dotnet publish -c Release -r win-x64 -o .\build-out -p:Version=$env:VERSION AMNet.Server\AMNet.Server.csproj + + - name: Upload artifact + run: | + curl -s -X POST -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" -H "Content-Type: application/octet-stream" --data-binary "@.\build-out\amnet.dll" "${{ needs.get-upload-url.outputs.upload_url }}?name=amnet.dll" + + build-website: + runs-on: ubuntu-latest + needs: get-upload-url + name: Build amnet-web + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install dependencies + working-directory: ${{ github.workspace }}/amnet-web + run: npm install + + - name: Build + working-directory: ${{ github.workspace }}/amnet-web + run: npm run build + + - name: Archive Result + run: zip -r amnet-web.zip ./amnet-web/dist/ + + - name: Upload + run: | + curl -s -X POST -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" -H "Content-Type: application/octet-stream" --data-binary "@./amnet-web.zip" "${{ needs.get-upload-url.outputs.upload_url }}?name=amnet-web.zip"