Skip to content

Commit

Permalink
ci: Simplify release version updates (#5724)
Browse files Browse the repository at this point in the history
lib/player.js was being updated separately because:

1. Originally, we didn't have support for updating arbitrary files with
release-please.
2. When we did get that support in release-please, it would trash the
"-uncompiled" tag we have in uncompiled mode.

By separating the uncompiled version string into two parts and using the
extra-files feature of release-please, we can get the updater to
preserve the "-uncompiled" tag and simplify the release workflow to only
update the PR once per change instead of twice.
  • Loading branch information
joeyparrish committed Oct 4, 2023
1 parent a478198 commit d1d67d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
29 changes: 2 additions & 27 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,8 @@ jobs:
default-branch: ${{ github.ref_name }}
# Use a special shaka-bot access token for releases.
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}

# If we didn't create a release, we may have created or updated a PR.
# Check out the code, then update the Player version in the PR.
- uses: actions/checkout@v3
if: steps.release.outputs.release_created == false
with:
# Use a special shaka-bot access token for releases.
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
- name: Custom update Player version
if: steps.release.outputs.release_created == false
run: |
# Check out the branch that release-please created.
# If it does not exist, FAIL!
git fetch
git checkout release-please--branches--${{ github.ref_name }}--components--shaka-player || exit 1
# If it does exist, update lib/player.js in the PR branch, so that the
# -uncompiled tag remains in the player version in that context.
VERSION="v$(jq -r .version package.json)-uncompiled"
sed -e "s/^\\(shaka.Player.version =\\).*/\\1 '$VERSION';/" \
-i lib/player.js
git add lib/player.js
# Set missing git config for the commit.
git config user.name "shaka-bot"
git config user.email "[email protected]"
# Update the PR.
git commit --amend --no-edit
git push -f
# Update these additional files containing version numbers.
extra-files: lib/player.js

# The jobs below are all conditional on a release having been created by
# someone merging the release PR. They all run in parallel.
Expand Down
5 changes: 5 additions & 0 deletions build/generateExterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ function createExternAssignment(name, node, alwaysIncludeConstructor) {
// Example extern: /** @const {string} */ foo.version;
return '';

case 'BinaryExpression':
// Example code: /** @const {string} @export */ foo.version = 'a' + 'b';
// Example extern: /** @const {string} */ foo.version;
return '';

default:
assert.fail('Unexpected export type: ' + node.type);
return ''; // Shouldn't be hit, but linter wants a return statement.
Expand Down
3 changes: 2 additions & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -6971,7 +6971,8 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
* @define {string} A version number taken from git at compile time.
* @export
*/
shaka.Player.version = 'v4.3.13-uncompiled';
// eslint-disable-next-line no-useless-concat
shaka.Player.version = 'v4.3.13' + '-uncompiled'; // x-release-please-version

// Initialize the deprecation system using the version string we just set
// on the player.
Expand Down

0 comments on commit d1d67d5

Please sign in to comment.