diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0289a80c..65230c39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -286,4 +286,72 @@ jobs: name: systemtests-linux-trx-v${{ needs.build.outputs.product_full_version }} if-no-files-found: error path: "TestResults/*.trx" - \ No newline at end of file + + release: + runs-on: ubuntu-latest + needs: [build, specs, system-tests-windows, system-tests-linux] + environment: production_environment + if: github.ref == 'refs/heads/main' && needs.build.outputs.deploy_packages == 'true' + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # added or changed files to the repository. + contents: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # avoid shallow clone git commit + ref: ${{ github.head_ref }} + ssh-key: ${{secrets.RELEASE_GIT_SSH_KEY}} + - uses: actions/download-artifact@v4 + with: + name: packages-v${{ needs.build.outputs.product_full_version }} + path: release_packages + - name: Display structure of downloaded files + run: ls -R + - name: Simulate Deployment + env: + NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }} + shell: pwsh + run: | + Write-Output "Deploying (prod: ${{ needs.build.outputs.deploy_packages }}) ${{ needs.build.outputs.product_full_version }} (${{ needs.build.outputs.product_main_version }}) / key: $env:NUGET_PUBLISH_KEY" + + - name: Calculate Next Version + if: needs.build.outputs.is_production_release == 'true' + id: next_version + shell: pwsh + run: | + $patchVersion = "${{ needs.build.outputs.product_patch_version }}" + $nextPatch = [int]$patchVersion + 1 + $nextVersion = "${{ needs.build.outputs.product_main_version }}.$nextPatch" + Write-Output "product_next_version=$nextVersion" >> $env:GITHUB_OUTPUT + Write-Output "Product Next Version: $nextVersion" + + - name: Bump Version + if: needs.build.outputs.is_production_release == 'true' + shell: pwsh + run: | + [System.IO.File]::WriteAllText("Directory.Build.props", [System.IO.File]::ReadAllText("Directory.Build.props").Replace("${{ needs.build.outputs.product_version_prefix }}", "${{ steps.next_version.outputs.product_next_version }}")) + git status + + - name: Update Changelog + if: needs.build.outputs.is_production_release == 'true' + shell: pwsh + run: | + $newHeading = "# [vNext]$([Environment]::NewLine)$([Environment]::NewLine)## Improvements:$([Environment]::NewLine)$([Environment]::NewLine)## Bug fixes:$([Environment]::NewLine)$([Environment]::NewLine)*Contributors of this release (in alphabetical order):* $([Environment]::NewLine)$([Environment]::NewLine)" + $releaseDate = [System.DateTime]::Today.ToString("yyyy-MM-dd") + $newHeading = $newHeading + "# ${{ needs.build.outputs.product_full_version }} - $releaseDate" + $content = [System.IO.File]::ReadAllText("CHANGELOG.md").Replace("# [vNext]",$newHeading) + [System.IO.File]::WriteAllText("CHANGELOG.md", $content) + + - name: Update changes in GitHub repository + if: needs.build.outputs.is_production_release == 'true' + run: | + git config --global user.name 'Reqnroll CI' + git config --global user.email 'ci@reqnroll.net' + git tag v${{ needs.build.outputs.product_full_version }} + git push --dry-run origin tag v${{ needs.build.outputs.product_full_version }} + git add -u + git commit -m '[automated commit] bump version after release of ${{ needs.build.outputs.product_full_version }}' + git push --dry-run + \ No newline at end of file