prepare-release #36
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
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: prepare-release | |
| description: Creates a release branch with version increment and merges it into main | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| project: | |
| description: 'Name of the project to prepare release for' | |
| type: choice | |
| required: true | |
| options: | |
| - Egil.Orleans.EventSourcing | |
| - Egil.Orleans.Storage | |
| - Egil.StronglyTypedPrimitives | |
| releaseType: | |
| description: 'Type of release' | |
| type: choice | |
| options: | |
| - minor | |
| - major | |
| default: minor | |
| permissions: | |
| contents: write | |
| jobs: | |
| prepare-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT_FOR_GIT_CONTENT_OPS }} | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| - name: Configure GIT | |
| run: | | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| - name: Prepare release | |
| id: prepare-release | |
| run: | | |
| cd ${{ inputs.project }} | |
| dotnet tool restore | |
| RELEASE_INFO=$(dotnet nbgv prepare-release --versionIncrement ${{ inputs.releaseType }} --commit-message-pattern "release: ${{ inputs.project }} - {0} release" --format json) | |
| echo "RELEASE_INFO<<EOF" >> $GITHUB_OUTPUT | |
| echo "$RELEASE_INFO" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| echo "$RELEASE_INFO" | jq . | |
| - name: Extract version change details | |
| id: extract-branch | |
| shell: bash | |
| run: | | |
| cd ${{ inputs.project }} | |
| RELEASE_INFO='${{ steps.prepare-release.outputs.RELEASE_INFO }}' | |
| NEW_BRANCH=$(echo "$RELEASE_INFO" | jq -r '.NewBranch.Name') | |
| echo "NEW_BRANCH=$NEW_BRANCH" >> $GITHUB_OUTPUT | |
| echo "New branch created: $NEW_BRANCH" | |
| MAIN_VERSION_COMMIT_MESSAGE=$(git log --format=%B -n 1 --skip 1) | |
| echo "MAIN_VERSION_COMMIT_MESSAGE=$MAIN_VERSION_COMMIT_MESSAGE" >> $GITHUB_OUTPUT | |
| echo "Commit message: $MAIN_VERSION_COMMIT_MESSAGE" | |
| MAIN_BRANCH_VERSION=$(echo "$RELEASE_INFO" | jq -r '.CurrentBranch.Version') | |
| echo "MAIN_BRANCH_VERSION=$MAIN_BRANCH_VERSION" >> $GITHUB_OUTPUT | |
| echo "New main branch version: $MAIN_BRANCH_VERSION" | |
| - name: Push release branch | |
| run: | | |
| git push origin ${{ steps.extract-branch.outputs.NEW_BRANCH }} | |
| echo "Pushed new branch: ${{ steps.extract-branch.outputs.NEW_BRANCH }}" | |
| - uses: actions/checkout@v4 | |
| name: Checkout main branch from Origin | |
| - name: Merge release branch into main | |
| shell: bash | |
| run: | | |
| cd ${{ inputs.project }} | |
| git merge -X ours origin/${{ steps.extract-branch.outputs.NEW_BRANCH }} | |
| echo "merged ${{ steps.extract-branch.outputs.NEW_BRANCH }} into main" | |
| dotnet nbgv set-version ${{ steps.extract-branch.outputs.MAIN_BRANCH_VERSION }} | |
| git commit -am "${{ steps.extract-branch.outputs.MAIN_VERSION_COMMIT_MESSAGE }}" | |
| echo "reapplied version changes to main" | |
| cat version.json | |
| - name: Push main branch | |
| run: | | |
| git push origin main | |
| echo "Pushed main branch" |