aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/update_release.yml
blob: 27d5e278369a0051a6181cbb785a89326b41a042 (plain) (blame)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Build release

on:
  # push
  pull_request:
    types: [closed]
    branches: [ main ]

jobs:
  windows-build:
    if: >-
      github.event.pull_request.merged == true &&
      contains( github.event.pull_request.labels.*.name, 'release')
    name: Build Windows
    runs-on: [self-hosted, windows, x64]
    strategy:
          matrix:
            config:
              - 'release'
            arch:
              - 'x64'
    env:
      VCPKG_VERSION: 2022.03.10

    steps:
    - uses: actions/checkout@v2

    - name: Setup xmake
      uses: xmake-io/github-action-setup-xmake@v1
      with:
        xmake-version: 2.6.4

    - name: Installing vcpkg
      run: |
        git clone -b ${{env.VCPKG_VERSION}} --single-branch https://github.com/Microsoft/vcpkg.git .vcpkg
        cd .vcpkg
        .\bootstrap-vcpkg.bat
        .\vcpkg.exe integrate install
        cd ..

    - name: Cache vcpkg
      uses: actions/cache@v2
      with:
        path: |
          ${{ github.workspace }}\.vcpkg\installed
        key: ${{ runner.os }}-${{ matrix.config }}-${{env.VCPKG_VERSION}}-${{ hashFiles('xmake.lua') }}-${{ matrix.arch }}-v5

    - name: Config
      run: |
        xmake config -v -y -m ${{ matrix.config }} --arch=${{ matrix.arch }}
      env:
        VCPKG_ROOT: ${{ github.workspace }}/.vcpkg

    - name: Build
      run: |
        xmake build -v -y
      env:
        VCPKG_ROOT: ${{ github.workspace }}/.vcpkg

    # - name: Create Archive
    #   run: |
    #     cd .\build\windows\${{ matrix.arch }}\${{ matrix.config }}
    #     C:\'Program Files'\7-Zip\7z.exe a -r ..\..\..\..\windows-${{ matrix.arch }}-${{ matrix.config }}.zip *
    #     cd ..\..\..\..

    - name: Create Archive
      run: |
        cd .\build\windows\${{ matrix.arch }}\${{ matrix.config }}
        C:\'Program Files'\7-Zip\7z.exe a -r ..\..\..\..\zenserver-win64.zip zenserver.exe
        cd ..\..\..\..

    - name: Get current release version info
      run: |
        $repo = "EpicGames/zen"
        $releases = "https://api.github.com/repos/$repo/releases/latest"
        Write-Host Determining latest release
        $latest = (Invoke-WebRequest -Headers @{"Accept"="application/vnd.github.v3+json";"Authorization"="token ${{ secrets.GITHUB_TOKEN }}"} $releases | ConvertFrom-Json)[0]
        $current_version_tag = [version]$latest.tag_name.replace('v','')
        echo "Current version" $current_version_tag
        if ($current_version_tag.Revision.Equals(9)) {
          if ($current_version_tag.Build.Equals(9)) {
            $new_version_tag = [version]::New($current_version_tag.Major,$current_version_tag.Minor+1,0,0).toString()
          }else {
            $new_version_tag = [version]::New($current_version_tag.Major,$current_version_tag.Minor,$current_version_tag.Build+1,0).toString()
          }
        }else {
          $new_version_tag = [version]::New($current_version_tag.Major,$current_version_tag.Minor,$current_version_tag.Build,$current_version_tag.Revision+1).toString()
        }
        echo $new_version_tag
        echo "new_version_tag=$new_version_tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: v${{ env.new_version_tag }}
        release_name: Release
        draft: false
        prerelease: false

    # - name: Create Release
    #   id: create_release
    #   uses: actions/create-release@v1
    #   env:
    #     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    #   with:
    #     tag_name: ${{ github.ref_name }}
    #     release_name: Release ${{ github.head_ref }}
    #     draft: false
    #     prerelease: false

    # - name: Upload Release Asset
    #   id: upload-release-asset 
    #   uses: actions/upload-release-asset@v1
    #   env:
    #     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    #   with:
    #     upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
    #     asset_path: .\windows-${{ matrix.arch }}-${{ matrix.config }}.zip
    #     asset_name: windows-${{ matrix.arch }}-${{ matrix.config }}
    #     asset_content_type: application/zip    
    - name: Upload Release Asset
      id: upload-release-asset 
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }} 
        asset_path: .\zenserver-win64.zip
        asset_name: zenserver-win64.zip
        asset_content_type: application/zip