Skip to content

Commit

Permalink
chore(ci): Auto-update README.md with versions
Browse files Browse the repository at this point in the history
Only happens while releasing on master:
* `NEXT_VERSION` should be used in all the `README.md` `since` columns.
* Links and url will automatically be updated to the latest release
  • Loading branch information
RomRider authored and jlsjonas committed Jan 22, 2022
1 parent 2426f17 commit 0d22b3b
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: workflow_dispatch
jobs:
release-bundle:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev'

outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
Expand Down
69 changes: 68 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@rollup/plugin-json": "^4.1.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"@semantic-release/github": "^7.2.0",
"@semantic-release/npm": "^7.0.9",
Expand All @@ -58,4 +59,4 @@
"watch": "rollup -c --watch",
"postversion": "npm run build"
}
}
}
42 changes: 27 additions & 15 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
/* eslint-disable no-template-curly-in-string */
module.exports = {
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
["@semantic-release/npm", {
"npmPublish": false,
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/changelog',
['@semantic-release/npm', {
npmPublish: false,
}],
["@semantic-release/github", {
"assets": "dist/*.js"
['@semantic-release/exec', {
prepareCmd: './scripts/update_readme.sh "${nextRelease.version}" "$GITHUB_REF"',
}],
"@semantic-release/git"
['@semantic-release/git', {
assets: [
'CHANGELOG.md',
'README.md',
'package.json',
'package-lock.json',
'npm-shrinkwrap.json',
],
}],
['@semantic-release/github', {
assets: 'dist/*.js',
}],
],
preset: 'angular',
branches: [
{ name: 'master' },
{ name: 'dev', prerelease: true },
],
"preset": "angular",
"branches": [
"master",
{ "name": "dev", "prerelease": true },
]
}
};
25 changes: 25 additions & 0 deletions scripts/update_readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

set -e

VERSION=$1
BRANCH=$2

if [ -z "${VERSION}" ]; then
echo "Version not specified; Exiting."
exit 1;
fi
if [ -z "${BRANCH}" ]; then
echo "Version not specified; Exiting."
exit 1;
fi

if [ ! "${BRANCH}" = "refs/heads/master" ]; then
echo "Branch is ${BRANCH}; README.md not updated."
exit 0;
fi

sed -i -e "s/NEXT_VERSION/v${VERSION}/g" ./README.md
sed -i -e "s|https://github.com/kalkih/mini-graph-card/releases/download/.*/mini-graph-card-bundle.js|https://github.com/kalkih/mini-graph-card/releases/download/v${VERSION}/mini-graph-card-bundle.js|g" ./README.md
sed -i -e "s|-\surl:\s/local/mini-graph-card-bundle.js?v=.*|- url: /local/mini-graph-card-bundle.js?v=${VERSION}|g" ./README.md

0 comments on commit 0d22b3b

Please sign in to comment.