forked from matrix-org/matrix-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Saner releases: improve drafts, handle offcycle releases, bump downst…
…ream projects (matrix-org#4044) * Switch prepublishOnly to prepack to catch errors earlier Signed-off-by: Michael Telatynski <[email protected]> * Fix merge-release-notes.js parsing Signed-off-by: Michael Telatynski <[email protected]> * Improve release drafts and make release-drafter handle offcycle releases better Signed-off-by: Michael Telatynski <[email protected]> * Tweak release-drafter config Signed-off-by: Michael Telatynski <[email protected]> * Automate downstream dependency bumping Signed-off-by: Michael Telatynski <[email protected]> * Remove duplicated docs Signed-off-by: Michael Telatynski <[email protected]> * Delint Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
- Loading branch information
Showing
11 changed files
with
180 additions
and
124 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Release Drafter | ||
on: | ||
workflow_call: | ||
inputs: | ||
include-changes: | ||
description: Project to include changelog entries from in this release. | ||
type: string | ||
required: false | ||
concurrency: release-drafter-action | ||
jobs: | ||
draft: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🧮 Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: staging | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: package.json | ||
cache: "yarn" | ||
|
||
- name: Install Deps | ||
run: "yarn install --frozen-lockfile" | ||
|
||
- uses: t3chguy/release-drafter@105e541c2c3d857f032bd522c0764694758fabad | ||
id: draft-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
disable-autolabeler: true | ||
|
||
- name: Get actions scripts | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: matrix-org/matrix-js-sdk | ||
persist-credentials: false | ||
path: .action-repo | ||
sparse-checkout: | | ||
.github/actions | ||
scripts/release | ||
- name: Ingest upstream changes | ||
if: inputs.include-changes | ||
uses: actions/github-script@v7 | ||
env: | ||
RELEASE_ID: ${{ steps.release.outputs.id }} | ||
DEPENDENCY: ${{ inputs.include-changes }} | ||
VERSION: ${{ steps.draft-release.outputs.tag_name }} | ||
with: | ||
retries: 3 | ||
script: | | ||
const { RELEASE_ID: releaseId, DEPENDENCY, VERSION } = process.env; | ||
const { owner, repo } = context.repo; | ||
const script = require("./.action-repo/scripts/release/merge-release-notes.js"); | ||
let deps = []; | ||
if (DEPENDENCY.includes("/")) { | ||
deps.push(DEPENDENCY.replace("$VERSION", VERSION)) | ||
} else { | ||
const fromVersion = JSON.parse(await exec.exec("git show origin/master:package.json")).dependencies[DEPENDENCY]; | ||
const toVersion = require("./package.json").dependencies[DEPENDENCY]; | ||
if (toVersion.endsWith("#develop")) { | ||
core.warning(`${DEPENDENCY} will be kept at ${fromVersion}`, { title: "Develop dependency found" }); | ||
} else { | ||
deps.push([DEPENDENCY, fromVersion, toVersion]); | ||
} | ||
} | ||
if (deps.length) { | ||
const notes = await script({ | ||
github, | ||
releaseId, | ||
dependencies: deps, | ||
}); | ||
await github.rest.repos.updateRelease({ | ||
owner, | ||
repo, | ||
release_id: releaseId, | ||
body: notes, | ||
}); | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,8 @@ on: | |
description: Publish to npm | ||
type: boolean | ||
default: false | ||
dependencies: | ||
description: | | ||
List of dependencies to update in `npm-dep=version` format. | ||
`version` can be `"current"` to leave it at the current version. | ||
downstreams: | ||
description: List of github projects (owner/repo) which should have their dependency bumped to the newly released version (in JSON string array string syntax) | ||
type: string | ||
required: false | ||
include-changes: | ||
|
@@ -88,17 +86,11 @@ jobs: | |
id: prepare | ||
run: | | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
{ | ||
echo "RELEASE_NOTES<<EOF" | ||
echo "$BODY" | ||
echo "EOF" | ||
} >> $GITHUB_ENV | ||
HAS_DIST=0 | ||
jq -e .scripts.dist package.json >/dev/null 2>&1 && HAS_DIST=1 | ||
echo "has-dist-script=$HAS_DIST" >> $GITHUB_OUTPUT | ||
env: | ||
BODY: ${{ steps.release.outputs.body }} | ||
VERSION: ${{ steps.release.outputs.tag_name }} | ||
|
||
- name: Finalise version | ||
|
@@ -132,76 +124,23 @@ jobs: | |
- name: Install dependencies | ||
run: "yarn install --frozen-lockfile" | ||
|
||
- name: Update dependencies | ||
id: update-dependencies | ||
if: inputs.dependencies | ||
run: | | ||
UPDATED=() | ||
while IFS= read -r DEPENDENCY; do | ||
[ -z "$DEPENDENCY" ] && continue | ||
IFS="=" read -r PACKAGE UPDATE_VERSION <<< "$DEPENDENCY" | ||
CURRENT_VERSION=$(cat package.json | jq -r .dependencies[\"$PACKAGE\"]) | ||
echo "Current $PACKAGE version is $CURRENT_VERSION" | ||
if [ "$CURRENT_VERSION" == "null" ] | ||
then | ||
echo "Unable to find $PACKAGE in package.json" | ||
exit 1 | ||
fi | ||
if [ "$UPDATE_VERSION" == "current" ] || [ "$UPDATE_VERSION" == "$CURRENT_VERSION" ] | ||
then | ||
echo "Not updating dependency $PACKAGE" | ||
continue | ||
fi | ||
echo "Upgrading $PACKAGE to $UPDATE_VERSION..." | ||
yarn upgrade "$PACKAGE@$UPDATE_VERSION" --exact | ||
git add -u | ||
git commit -m "Upgrade $PACKAGE to $UPDATE_VERSION" | ||
UPDATED+=("$PACKAGE") | ||
done <<< "$DEPENDENCIES" | ||
JSON=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${UPDATED[@]}") | ||
echo "updated=$JSON" >> $GITHUB_OUTPUT | ||
env: | ||
DEPENDENCIES: ${{ inputs.dependencies }} | ||
|
||
- name: Prevent develop dependencies | ||
if: inputs.dependencies | ||
- name: Handle develop dependencies | ||
run: | | ||
ret=0 | ||
cat package.json | jq '.dependencies[]' | grep -q '#develop' || ret=$? | ||
if [ "$ret" -eq 0 ]; then | ||
echo "package.json contains develop dependencies. Refusing to release." | ||
exit | ||
fi | ||
cat package.json | jq -r '.dependencies | to_entries | .[] | "\(.key) \(.value)"' | grep '#develop$' | while read -r dep ; do | ||
IFS=" " | ||
PACKAGE=${dep[0]} | ||
VERSION=${dep[1]} | ||
echo "::warning title=Develop dependency found::$DEPENDENCY will be kept at $VERSION" | ||
yarn upgrade "$PACKAGE@$VERSION" --exact | ||
git add -u | ||
git commit -m "Keep $PACKAGE at $VERSION" | ||
done | ||
- name: Bump package.json version | ||
run: yarn version --no-git-tag-version --new-version "${VERSION#v}" | ||
|
||
- name: Ingest upstream changes | ||
if: | | ||
inputs.include-changes && | ||
(!inputs.dependencies || contains(fromJSON(steps.update-dependencies.outputs.updated), inputs.include-changes)) | ||
uses: actions/github-script@v7 | ||
env: | ||
RELEASE_ID: ${{ steps.release.outputs.id }} | ||
DEPENDENCY: ${{ inputs.include-changes }} | ||
with: | ||
retries: 3 | ||
script: | | ||
const { RELEASE_ID: releaseId, DEPENDENCY, VERSION } = process.env; | ||
const { owner, repo } = context.repo; | ||
const script = require("./.action-repo/scripts/release/merge-release-notes.js"); | ||
const notes = await script({ | ||
github, | ||
releaseId, | ||
dependencies: [DEPENDENCY.replace("$VERSION", VERSION)], | ||
}); | ||
core.exportVariable("RELEASE_NOTES", notes); | ||
- name: Add to CHANGELOG.md | ||
if: inputs.final | ||
run: | | ||
|
@@ -219,6 +158,8 @@ jobs: | |
cat CHANGELOG.md.old >> CHANGELOG.md | ||
rm CHANGELOG.md.old | ||
git add CHANGELOG.md | ||
env: | ||
RELEASE_NOTES: ${{ steps.release.outputs.body }} | ||
|
||
- name: Run pre-release script to update package.json fields | ||
run: | | ||
|
@@ -351,3 +292,31 @@ jobs: | |
filter-labels: X-Upcoming-Release-Blocker | ||
remove-labels: X-Upcoming-Release-Blocker | ||
add-labels: X-Release-Blocker | ||
|
||
bump-downstreams: | ||
name: Update npm dependency in downstream projects | ||
needs: npm | ||
runs-on: ubuntu-latest | ||
if: inputs.downstreams | ||
strategy: | ||
matrix: | ||
repo: ${{ fromJSON(inputs.downstreams) }} | ||
steps: | ||
- name: Checkout Element Desktop | ||
uses: actions/checkout@v4 | ||
if: inputs.element-desktop | ||
with: | ||
repository: ${{ matrix.repo }} | ||
ref: staging | ||
token: ${{ secrets.ELEMENT_BOT_TOKEN }} | ||
|
||
- name: Bump dependency | ||
env: | ||
DEPENDENCY: ${{ needs.npm.outputs.id }} | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "RiotRobot" | ||
yarn upgrade "$DEPENDENCY" --exact | ||
git add package.json yarn.lock | ||
git commit -am"Upgrade dependency to $DEPENDENCY" | ||
git push origin staging |
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.