-
Notifications
You must be signed in to change notification settings - Fork 73
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
Release helper script and CI #452
Merged
+92
−9
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4bc6c16
Remove container version
Half-Shot 60645b8
Add release script
Half-Shot 7b42c0b
Add
Half-Shot d97fc6e
Add npm publish script
Half-Shot 909a601
Remove unused id
Half-Shot 2f01c70
Testing tag publish
Half-Shot dde54a0
Commit the version
Half-Shot 700db2f
Tidy up scripts
Half-Shot 4ea75f2
Update release.yml
Half-Shot 3ef9c2c
Update release.sh
Half-Shot 7a6d4bb
Cleanup
Half-Shot 710e698
changelog
Half-Shot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish-to-npm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- run: yarn --strict-semver --frozen-lockfile | ||
- run: yarn build | ||
- uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} |
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,24 @@ | ||
on: | ||
push: | ||
tags: ["[0-9].[0-9].[0-9]"] | ||
|
||
jobs: | ||
draft-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Get changelog | ||
id: extract-changelog | ||
run: | | ||
git fetch --tags --force | ||
RELEASE_NAME="${{ github.ref_name }} $(date +'%Y-%m-%d')" | ||
git tag -l --format='%(contents:body)' ${{ github.ref_name }} > next-changelog.txt | ||
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_OUTPUT | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ github.ref }} | ||
name: ${{ steps.extract-changelog.outputs.RELEASE_NAME }} | ||
body_path: next-changelog.txt | ||
draft: true # Draft it | ||
token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token |
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 @@ | ||
Add `release.sh` script to automate the release process. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
# This script will run towncrier to and generate a release commit, tag and push to the origin. | ||
|
||
if ! command -v jq &> /dev/null | ||
then | ||
echo "You must install jq to use this script" | ||
exit | ||
fi | ||
|
||
VERSION=`jq -r .version package.json` | ||
TAG="$VERSION" | ||
|
||
if [[ "`git branch --show-current`" != "develop" ]]; then | ||
echo "You must be on the develop branch to run this command." | ||
exit 1 | ||
fi | ||
|
||
if [ $(git tag -l "$TAG") ]; then | ||
echo "Tag $TAG already exists, not continuing." | ||
exit 1 | ||
fi | ||
|
||
echo "Drafting a new release" | ||
towncrier build --draft --version $VERSION> draft-release.txt | ||
cat draft-release.txt | ||
|
||
read -p "Happy with the changelog? <y/N> " prompt | ||
if [[ $prompt != "y" && $prompt != "Y" && $prompt != "yes" && $prompt != "Yes" ]] | ||
then | ||
exit 0 | ||
fi | ||
|
||
echo "Committing version" | ||
towncrier build --version $VERSION | ||
git commit CHANGELOG.md changelog.d/ package.json -m $TAG | ||
|
||
echo "Proceeding to generate tags" | ||
cat draft-release.txt | git tag --force -m - -s $TAG | ||
rm draft-release.txt | ||
echo "Generated tag $TAG" | ||
|
||
echo "Pushing to origin" | ||
git push origin $TAG | ||
# Push develop too | ||
git push | ||
|
||
echo "The CI to generate a release is now running. Check https://github.com/matrix-org/matrix-appservice-bridge/releases and publish the release when it's ready." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This obviously doesn't allow us to do a PR for releases, which may not be desirable. Thoughts on how this could be re-architected to support that are welcome. Alternatively we can forgo the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PRs for releases can be a bit of a pain, and are probably redundant since we usually discuss release plans internally before publishing anything. So I'm in favour of forgoing.