aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/upload-win-installer.yml
blob: 125100a28175c0d592b1c03f9d065a3b9571c153 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Upload Windows Installer

on:
  release:
    types: [created, published, edited]
  workflow_dispatch:
    inputs:
      version:
        description: 'Release version to build and upload (e.g. "4.2.1")'
        required: true
jobs:
  build:
    runs-on: windows-latest
    env:
        FETCH_BASE_URL: ${{ github.server_url }}/${{ github.repository }}
    steps:
    - name: Determine version
      id: getversion
      run: |
        $version = "${{ inputs.version }}"
        if ($version.Length -lt 1) {
          $version = "${{ github.event.release.tag_name }}"
          if ($version.Length -lt 1) {
            Write-Host "Could not determine version!"
            Exit 1
          }
        }
        Write-Output "::set-output name=version::$version"
    - uses: actions/checkout@v3
    - name: Check
      id: check
      run: |
        Push-Location contrib\win-installer
        .\check.ps1 ${{steps.getversion.outputs.version}}
        $code = $LASTEXITCODE
        if ($code -eq 2) {
          Write-Output "::set-output name=already-exists::true"
          Pop-Location
          Exit 0
        }
        Write-Output "UPLOAD_ASSET_NAME=$env:UPLOAD_ASSET_NAME" | Out-File -FilePath $env:GITHUB_ENV -Append
        Pop-Location
        Exit $code
    - name: Set up Go
      uses: actions/setup-go@v3
      if: steps.check.outputs.already-exists != 'true'
      with:
        go-version: 1.18
    - name: Setup Signature Tooling
      if: steps.Check.outputs.already-exists != 'true'
      run: |
          dotnet tool install --global AzureSignTool --version 3.0.0
          echo "CERT_NAME=${{secrets.AZ_CERT_NAME}}" | Out-File -FilePath $env:GITHUB_ENV -Append
          echo "VAULT_ID=${{secrets.AZ_VAULT_ID}}" | Out-File -FilePath $env:GITHUB_ENV -Append
          echo "APP_ID=${{secrets.AZ_APP_ID}}" | Out-File -FilePath $env:GITHUB_ENV -Append
          echo "TENANT_ID=${{secrets.AZ_TENANT_ID}}" | Out-File -FilePath $env:GITHUB_ENV -Append
          echo "CLIENT_SECRET=${{secrets.AZ_CLIENT_SECRET}}" | Out-File -FilePath $env:GITHUB_ENV -Append
    - name: Build
      id: build
      if: steps.check.outputs.already-exists != 'true'
      run: |
        Push-Location contrib\win-installer
        .\build.ps1 ${{steps.getversion.outputs.version}} prod
        $code = $LASTEXITCODE
        if ($code -eq 2) {
          Write-Output "::set-output name=artifact-missing::true"
          Pop-Location
          Exit 0
        }
        Pop-Location
        Exit $code
    - name: Upload
      if: steps.check.outputs.already-exists != 'true' && steps.build.outputs.artifact-missing != 'true'
      env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
        Push-Location contrib\win-installer
        $version = "${{ steps.getversion.outputs.version }}"
        if ($version[0] -ne "v") {
          $version = "v$version"
        }
        gh release upload $version $ENV:UPLOAD_ASSET_NAME
        if ($LASTEXITCODE -ne 0) {
          .\check.ps1 $version
          if ($LASTEXITCODE -eq 2) {
            Write-Host "Another job uploaded before us, skipping"
            Pop-Location
            Exit 0
          }
          Pop-Location
          Exit 1
        }
        if (Test-Path -Path shasums) {
          gh release upload --clobber $version shasums
        }
        Pop-Location