Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve release workflows by auto-detecting release date #365

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions .github/workflows/finish-release-train.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,63 @@ 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:
version_number: ${{ steps.version_number.outputs.version_number }}
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 "[email protected]"

- name: Detect version number
id: version_number
run: |
version_number="$(jq --raw-output '.version' package.json)"
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The date auto-generation happens here in $(date +'%Y-%m-%d')


- 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: |
Expand All @@ -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
Expand All @@ -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 }}

Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/start-release-train.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down