Skip to content

Commit a6be350

Browse files
authored
Release helper script and CI (#452)
* Remove container version * Add release script * Add * Add npm publish script * Remove unused id * Testing tag publish fix ref name change the command fetch depth Try checking out the tag Remove tag check Releasey bits Tag file Try fetching all tags Ask it very nicely to fetch tags needs a force to make it happy Finally get tags working fix fails Simpify Correct param Fix name s/file/path Update release script Test publish workflow forgot to checkout test publication Use npm publish Use proper publish script * Commit the version * Tidy up scripts * Update release.yml * Update release.sh * Cleanup * changelog
1 parent 9dac938 commit a6be350

File tree

6 files changed

+92
-9
lines changed

6 files changed

+92
-9
lines changed

.github/workflows/npm-publish.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
release:
3+
types: [published]
4+
5+
jobs:
6+
publish-to-npm:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: Use Node.js
11+
uses: actions/setup-node@v3
12+
with:
13+
node-version: 18
14+
- run: yarn --strict-semver --frozen-lockfile
15+
- run: yarn build
16+
- uses: JS-DevTools/npm-publish@v1
17+
with:
18+
token: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on:
2+
push:
3+
tags: ["[0-9].[0-9].[0-9]"]
4+
5+
jobs:
6+
draft-release:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: Get changelog
11+
id: extract-changelog
12+
run: |
13+
git fetch --tags --force
14+
RELEASE_NAME="${{ github.ref_name }} $(date +'%Y-%m-%d')"
15+
git tag -l --format='%(contents:body)' ${{ github.ref_name }} > next-changelog.txt
16+
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_OUTPUT
17+
- name: Create Release
18+
uses: softprops/action-gh-release@v1
19+
with:
20+
tag_name: ${{ github.ref }}
21+
name: ${{ steps.extract-changelog.outputs.RELEASE_NAME }}
22+
body_path: next-changelog.txt
23+
draft: true # Draft it
24+
token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token

.github/workflows/test.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Tests
33
on:
44
push:
55
workflow_dispatch:
6-
pull_request:
76

87
jobs:
98
lint:
@@ -12,7 +11,7 @@ jobs:
1211
steps:
1312
- uses: actions/checkout@v2
1413
- name: Use Node.js
15-
uses: actions/setup-node@v1
14+
uses: actions/setup-node@v3
1615
with:
1716
node-version: 16
1817
- run: yarn --strict-semver --frozen-lockfile
@@ -23,7 +22,6 @@ jobs:
2322
matrix:
2423
node-version: [16, 18]
2524
runs-on: ubuntu-20.04
26-
container: node:14
2725
steps:
2826
- uses: actions/checkout@v2
2927
- name: Use Node.js
@@ -53,7 +51,7 @@ jobs:
5351
steps:
5452
- uses: actions/checkout@v2
5553
- name: Use Node.js
56-
uses: actions/setup-node@v1
54+
uses: actions/setup-node@v3
5755
with:
5856
node-version: 18
5957
- run: yarn --frozen-lockfile

changelog.d/452.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `release.sh` script to automate the release process.

scripts/changelog-release.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/release.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# This script will run towncrier to and generate a release commit, tag and push to the origin.
3+
4+
if ! command -v jq &> /dev/null
5+
then
6+
echo "You must install jq to use this script"
7+
exit
8+
fi
9+
10+
VERSION=`jq -r .version package.json`
11+
TAG="$VERSION"
12+
13+
if [[ "`git branch --show-current`" != "develop" ]]; then
14+
echo "You must be on the develop branch to run this command."
15+
exit 1
16+
fi
17+
18+
if [ $(git tag -l "$TAG") ]; then
19+
echo "Tag $TAG already exists, not continuing."
20+
exit 1
21+
fi
22+
23+
echo "Drafting a new release"
24+
towncrier build --draft --version $VERSION> draft-release.txt
25+
cat draft-release.txt
26+
27+
read -p "Happy with the changelog? <y/N> " prompt
28+
if [[ $prompt != "y" && $prompt != "Y" && $prompt != "yes" && $prompt != "Yes" ]]
29+
then
30+
exit 0
31+
fi
32+
33+
echo "Committing version"
34+
towncrier build --version $VERSION
35+
git commit CHANGELOG.md changelog.d/ package.json -m $TAG
36+
37+
echo "Proceeding to generate tags"
38+
cat draft-release.txt | git tag --force -m - -s $TAG
39+
rm draft-release.txt
40+
echo "Generated tag $TAG"
41+
42+
echo "Pushing to origin"
43+
git push origin $TAG
44+
# Push develop too
45+
git push
46+
47+
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."

0 commit comments

Comments
 (0)