Deploy head #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Deploy head" | |
| on: | |
| workflow_run: | |
| workflows: | |
| - CI | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| deployments: write | |
| jobs: | |
| check: | |
| name: "Check skip" | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| is_newer: ${{ steps.step1.outputs.result }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check agains head | |
| id: step1 | |
| shell: pwsh | |
| run: | | |
| git merge-base --is-ancestor refs/tags/head ${{ github.sha }} | |
| echo "Result: $LASTEXITCODE" | |
| if($LASTEXITCODE -eq 0) { | |
| "result=1" | Out-File -Path $env:GITHUB_OUTPUT -Append | |
| } | |
| elseif($LASTEXITCODE -eq 1) { | |
| "result=0" | Out-File -Path $env:GITHUB_OUTPUT -Append | |
| exit 0 | |
| } | |
| tag: | |
| name: "Update tag" | |
| runs-on: ubuntu-22.04 | |
| needs: check | |
| if: needs.check.outputs.is_newer == 1 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Update head tag | |
| run: | | |
| git push --delete origin head | |
| git tag head | |
| git push origin head | |
| assets: | |
| name: "Upload assets" | |
| runs-on: ubuntu-22.04 | |
| needs: check | |
| if: needs.check.outputs.is_newer == 1 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: [windows, linux] | |
| include: | |
| - platform: windows | |
| arch: x86_64 | |
| release-ext: zip | |
| release-type: application/zip | |
| - platform: linux | |
| arch: x86_64 | |
| release-ext: tar.gz | |
| release-type: application/gzip | |
| steps: | |
| - name: Download build artifacts (server) | |
| uses: dawidd6/action-download-artifact@v6 | |
| with: | |
| workflow: ci.yml | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: snail-server-${{ matrix.arch }}-${{ matrix.platform }} | |
| path: bin | |
| - name: Download build artifacts (tools) | |
| uses: dawidd6/action-download-artifact@v6 | |
| with: | |
| workflow: ci.yml | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: snail-tools-${{ matrix.arch }}-${{ matrix.platform }} | |
| path: tools/bin | |
| - name: Download build artifacts (server, symbols) | |
| uses: dawidd6/action-download-artifact@v6 | |
| if: matrix.platform == 'windows' | |
| with: | |
| workflow: ci.yml | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: snail-server-${{ matrix.arch }}-${{ matrix.platform }}-debug-symbols | |
| skip_unpack: true | |
| - name: Download build artifacts (tools, symbols) | |
| uses: dawidd6/action-download-artifact@v6 | |
| if: matrix.platform == 'windows' | |
| with: | |
| workflow: ci.yml | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: snail-tools-${{ matrix.arch }}-${{ matrix.platform }}-debug-symbols | |
| skip_unpack: true | |
| - name: Repack release asset (zip) | |
| if: matrix.release-ext == 'zip' | |
| run: | | |
| mv ${{ github.workspace }}/bin/info.txt ${{ github.workspace }}/info.txt | |
| zip snail-server-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }} bin/* info.txt | |
| mv ${{ github.workspace }}/tools/bin/info.txt ${{ github.workspace }}/tools/info.txt | |
| cd tools | |
| zip snail-tools-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }} bin/* info.txt | |
| - name: Repack release asset (tar.gz) | |
| if: matrix.release-ext == 'tar.gz' | |
| run: | | |
| mv ${{ github.workspace }}/bin/info.txt ${{ github.workspace }}/info.txt | |
| tar -cvzf snail-server-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }} bin info.txt | |
| mv ${{ github.workspace }}/tools/bin/info.txt ${{ github.workspace }}/tools/info.txt | |
| cd tools | |
| tar -cvzf snail-tools-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }} bin info.txt | |
| - name: Upload release asset (server) | |
| shell: pwsh | |
| run: | | |
| $assetId = curl -L ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| https://api.github.com/repos/albertziegenhagel/snail-server/releases/110773624/assets | ` | |
| ConvertFrom-Json | ` | |
| Where-Object -Property name -Value "snail-server-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }}" -EQ | ` | |
| Select-Object -Expand id | |
| if($assetId) { | |
| curl -L ` | |
| -X DELETE ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| https://api.github.com/repos/albertziegenhagel/snail-server/releases/assets/$assetId | |
| } | |
| curl -i -X POST ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| -H "Content-Type: ${{ matrix.release-type }}" ` | |
| --data-binary "@snail-server-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }}" ` | |
| "https://uploads.github.com/repos/albertziegenhagel/snail-server/releases/110773624/assets?name=snail-server-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }}" | |
| - name: Upload release asset (tools) | |
| shell: pwsh | |
| run: | | |
| $assetId = curl -L ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| https://api.github.com/repos/albertziegenhagel/snail-server/releases/110773624/assets | ` | |
| ConvertFrom-Json | ` | |
| Where-Object -Property name -Value "snail-tools-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }}" -EQ | ` | |
| Select-Object -Expand id | |
| if($assetId) { | |
| curl -L ` | |
| -X DELETE ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| https://api.github.com/repos/albertziegenhagel/snail-server/releases/assets/$assetId | |
| } | |
| curl -i -X POST ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| -H "Content-Type: ${{ matrix.release-type }}" ` | |
| --data-binary "@tools/snail-tools-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }}" ` | |
| "https://uploads.github.com/repos/albertziegenhagel/snail-server/releases/110773624/assets?name=snail-tools-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.release-ext }}" | |
| - name: Upload release asset (server, symbols) | |
| if: matrix.platform == 'windows' | |
| shell: pwsh | |
| run: | | |
| $assetId = curl -L ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| https://api.github.com/repos/albertziegenhagel/snail-server/releases/110773624/assets | ` | |
| ConvertFrom-Json | ` | |
| Where-Object -Property name -Value "snail-server-${{ matrix.arch }}-${{ matrix.platform }}-debug-symbols.zip" -EQ | ` | |
| Select-Object -Expand id | |
| if($assetId) { | |
| curl -L ` | |
| -X DELETE ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| https://api.github.com/repos/albertziegenhagel/snail-server/releases/assets/$assetId | |
| } | |
| curl -i -X POST ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| -H "Content-Type: ${{ matrix.release-type }}" ` | |
| --data-binary "@snail-server-${{ matrix.arch }}-${{ matrix.platform }}-debug-symbols.zip" ` | |
| "https://uploads.github.com/repos/albertziegenhagel/snail-server/releases/110773624/assets?name=snail-server-${{ matrix.arch }}-${{ matrix.platform }}-debug-symbols.zip" | |
| - name: Upload release asset (tools, symbols) | |
| if: matrix.platform == 'windows' | |
| shell: pwsh | |
| run: | | |
| $assetId = curl -L ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| https://api.github.com/repos/albertziegenhagel/snail-server/releases/110773624/assets | ` | |
| ConvertFrom-Json | ` | |
| Where-Object -Property name -Value "snail-tools-${{ matrix.arch }}-${{ matrix.platform }}-debug-symbols.zip" -EQ | ` | |
| Select-Object -Expand id | |
| if($assetId) { | |
| curl -L ` | |
| -X DELETE ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| https://api.github.com/repos/albertziegenhagel/snail-server/releases/assets/$assetId | |
| } | |
| curl -i -X POST ` | |
| -H "Accept: application/vnd.github+json" ` | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ` | |
| -H "X-GitHub-Api-Version: 2022-11-28" ` | |
| -H "Content-Type: ${{ matrix.release-type }}" ` | |
| --data-binary "@snail-tools-${{ matrix.arch }}-${{ matrix.platform }}-debug-symbols.zip" ` | |
| "https://uploads.github.com/repos/albertziegenhagel/snail-server/releases/110773624/assets?name=snail-tools-${{ matrix.arch }}-${{ matrix.platform }}-debug-symbols.zip" | |
| publish: | |
| name: "Puplish" | |
| runs-on: ubuntu-22.04 | |
| needs: | |
| - tag | |
| - assets | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Mark release as non-draft | |
| run: | | |
| curl -L -X PATCH \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "https://api.github.com/repos/albertziegenhagel/snail-server/releases/110773624" \ | |
| -d '{"draft":false}' |