|
| 1 | +name: Branch Build Using Docker |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - feature/* |
| 7 | + - hotfix/* |
| 8 | + - release/* |
| 9 | + - master |
| 10 | + - development |
| 11 | + |
| 12 | +env: |
| 13 | + # solution path doesn't need slashes unless there it is multiple folders deep |
| 14 | + # solution name does not include extension. .sln is assumed |
| 15 | + SOLUTION_PATH: PDT.EssentialsPluginTemplate.EPI |
| 16 | + SOLUTION_FILE: PDT.EssentialsPluginTemplate.EPI |
| 17 | + # Do not edit this, we're just creating it here |
| 18 | + VERSION: 0.0.0-buildtype-buildnumber |
| 19 | + # Defaults to debug for build type |
| 20 | + BUILD_TYPE: Debug |
| 21 | + # Defaults to master as the release branch. Change as necessary |
| 22 | + RELEASE_BRANCH: master |
| 23 | +jobs: |
| 24 | + Build_Project: |
| 25 | + runs-on: windows-latest |
| 26 | + steps: |
| 27 | + # First we checkout the source repo |
| 28 | + - name: Checkout repo |
| 29 | + uses: actions/checkout@v2 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + # And any submodules |
| 33 | + - name: Checkout submodules |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + git config --global url."https://github.com/".insteadOf "[email protected]:" |
| 37 | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" |
| 38 | + git submodule sync --recursive |
| 39 | + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 |
| 40 | + # Set the BUILD_TYPE environment variable |
| 41 | + - name: Set Build to Release if triggered from Master |
| 42 | + run: | |
| 43 | + if("$($Env:GITHUB_REF)".contains("$($Env:RELEASE_BRANCH)")) { |
| 44 | + Write-Host "Setting build type to Release" |
| 45 | + Write-Output "::set-env name=BUILD_TYPE::Release" |
| 46 | + } |
| 47 | + # Fetch all tags |
| 48 | + - name: Fetch tags |
| 49 | + run: git fetch --tags |
| 50 | + # Generate the appropriate version number |
| 51 | + - name: Set Version Number |
| 52 | + shell: powershell |
| 53 | + run: | |
| 54 | + $version = ./.github/scripts/GenerateVersionNumber.ps1 |
| 55 | + Write-Output "::set-env name=VERSION::$version" |
| 56 | + # Use the version number to set the version of the assemblies |
| 57 | + - name: Update AssemblyInfo.cs |
| 58 | + shell: powershell |
| 59 | + run: | |
| 60 | + Write-Output ${{ env.VERSION }} |
| 61 | + ./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }} |
| 62 | + # Build the solutions in the docker image |
| 63 | + - name: Build Solution |
| 64 | + shell: powershell |
| 65 | + run: | |
| 66 | + Invoke-Expression "docker run --rm --mount type=bind,source=""$($Env:GITHUB_WORKSPACE)"",target=""c:/project"" pepperdash/sspbuilder c:\cihelpers\vsidebuild.exe -Solution ""c:\project\$($Env:SOLUTION_PATH)\$($Env:SOLUTION_FILE).sln"" -BuildSolutionConfiguration $($ENV:BUILD_TYPE)" |
| 67 | + # Zip up the output files as needed |
| 68 | + - name: Zip Build Output |
| 69 | + shell: powershell |
| 70 | + run: ./.github/scripts/ZipBuildOutput.ps1 |
| 71 | + - name: Upload Build Output |
| 72 | + uses: actions/upload-artifact@v1 |
| 73 | + with: |
| 74 | + name: Build |
| 75 | + path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip |
| 76 | + # Create the release on the source repo |
| 77 | + - name: Create Release |
| 78 | + id: create_release |
| 79 | + uses: actions/create-release@v1 |
| 80 | + with: |
| 81 | + tag_name: ${{ env.VERSION }} |
| 82 | + release_name: ${{ env.VERSION }} |
| 83 | + prerelease: ${{contains('debug', env.BUILD_TYPE)}} |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + # Upload the build package to the release |
| 87 | + - name: Upload Release Package |
| 88 | + id: upload_release |
| 89 | + uses: actions/upload-release-asset@v1 |
| 90 | + with: |
| 91 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 92 | + asset_path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip |
| 93 | + asset_name: ${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip |
| 94 | + asset_content_type: application/zip |
| 95 | + env: |
| 96 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments