diff --git a/.github/workflows/finish-release-train.yml b/.github/workflows/finish-release-train.yml index 83a9fd82..3ea4c33c 100644 --- a/.github/workflows/finish-release-train.yml +++ b/.github/workflows/finish-release-train.yml @@ -15,7 +15,7 @@ concurrency: cancel-in-progress: true jobs: - create_pr: + prepare: if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/v') runs-on: ubuntu-latest outputs: @@ -23,6 +23,12 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup Git User + run: | + # setup git + git config --global user.name "Bitmovin Release Automation" + git config --global user.email "support@bitmovin.com" + - name: Detect version number id: version_number run: | @@ -30,24 +36,42 @@ jobs: echo "Detected version number: $version_number" echo "version_number=$version_number" >> $GITHUB_OUTPUT + - name: Update Changelog + run: | + sed -i "s/\[${{ steps.version_number.outputs.version_number }}\].*/\[${{ steps.version_number.outputs.version_number }}\] \($(date +'%Y-%m-%d')\)/g" CHANGELOG.md + + - name: Commit changelog version bump + run: | + git add CHANGELOG.md + git commit -m "chore: bump changelog date to today" + git push origin ${{ github.ref }} + + create_pr: + needs: [prepare] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create PR run: | gh pr create \ --base "development" \ --head "main" \ - --title "Finish release ${{ steps.version_number.outputs.version_number }}" \ - --body "Finish release ${{ steps.version_number.outputs.version_number }}" + --title "Finish release ${{ needs.prepare.outputs.version_number }}" \ + --body "Finish release ${{ needs.prepare.outputs.version_number }}" env: GH_TOKEN: ${{ github.token }} publish_release: - needs: [create_pr] + needs: [prepare, create_pr] runs-on: ubuntu-latest permissions: contents: write steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ github.ref_name }} - name: Setup Git User run: | @@ -57,11 +81,11 @@ jobs: - name: Add tag run: | - git tag v${{ needs.create_pr.outputs.version_number }} + git tag v${{ needs.prepare.outputs.version_number }} - name: Git push run: | - git push origin v${{ needs.create_pr.outputs.version_number }} + git push origin v${{ needs.prepare.outputs.version_number }} - name: Setup node and npm registry uses: actions/setup-node@v3 @@ -88,7 +112,7 @@ jobs: - name: Create GitHub release uses: ncipollo/release-action@v1 with: - tag: v${{ needs.create_pr.outputs.version_number }} + tag: v${{ needs.prepare.outputs.version_number }} token: ${{ secrets.GITHUB_TOKEN }} body: ${{ steps.changelog.outputs.release_notes }} diff --git a/.github/workflows/start-release-train.yml b/.github/workflows/start-release-train.yml index 2d111ce5..98719613 100644 --- a/.github/workflows/start-release-train.yml +++ b/.github/workflows/start-release-train.yml @@ -6,10 +6,6 @@ on: description: 'Next version number of the release' type: string required: true - release_date: - description: 'Date of the final release. Will be used for CHANGELOG.md (format YYYY-MM-DD, e.g. 2023-02-27)' - type: string - required: true dry_run: description: 'If true, the workflow will not create a PR' type: boolean @@ -59,7 +55,7 @@ jobs: - name: Bump changelog version run: | - sed -i'.bak' "s/\[Unreleased\]/\[${{ inputs.version_number }}\] \(${{ inputs.release_date }}\)/g" CHANGELOG.md + sed -i'.bak' "s/\[Unreleased\]/\[${{ inputs.version_number }}\]/g" CHANGELOG.md awk 'BEGIN {count=0} /## \[/ {count++; if (count == 2) exit} {print}' CHANGELOG.md - name: Bump package.json version