Skip to content

Commit

Permalink
Merge cf5fa84 into 742860f
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Mar 12, 2023
2 parents 742860f + cf5fa84 commit 0f0aa30
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 51 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: wavesurfer.js
name: Lint & tests

on:
push:
Expand All @@ -8,7 +8,6 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand Down
73 changes: 31 additions & 42 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: NPM Package
name: Release

on:
push:
branches: [ master ]
branches:
- master

permissions:
contents: write
Expand All @@ -11,57 +12,45 @@ jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Checkout
uses: actions/checkout@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Cache Node.js modules
uses: actions/cache@v3
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- run: npm install
fetch-depth: 0

- name: Extract version
id: version
run: |
OLD_VERSION=$(npm show wavesurfer.js version)
NEW_VERSION=$(node -p 'require("./package.json").version')
if [ $NEW_VERSION != $OLD_VERSION ]; then
echo $NEW_VERSION > version.txt
echo "New version $NEW_VERSION detected"
echo "::set-output name=version::$NEW_VERSION"
git log "$OLD_VERSION"..HEAD --pretty=format:"* %s" > TEMP_CHANGELOG.md
else
echo "Version $OLD_VERSION hasn't changed, skipping the release"
exit 1
fi
- name: Create a git tag
run: |
if [ -f version.txt ]; then
echo "Creating a git tag"
git tag $(cat version.txt)
git push --tags
fi
if: success()
run: git tag $NEW_VERSION && git push --tags
env:
NEW_VERSION: ${{ steps.version.outputs.version }}

- name: GitHub release
if: success()
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: ${{ steps.version.outputs.version }}
tag_name: ${{ steps.version.outputs.version }}
body_path: TEMP_CHANGELOG.md
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
run: |
if [ -f version.txt ]; then
echo "Publishing to NPM"
npm publish
fi
- name: Release on GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -f version.txt ]; then
NEW_VERSION=$(cat version.txt)
echo "Releasing $NEW_VERSION on GitHub"
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
'https://api.github.com/repos/wavesurfer-js/wavesurfer.js/releases' \
-d "{\"tag_name\":\"$NEW_VERSION\", \"name\": \"$NEW_VERSION\"}"
fi
run: npm publish
9 changes: 5 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ wavesurfer.js changelog
------------------
- Regions plugin:
- Improved delta calculation (resize end) (#2641)
- Editable text in regions (#2521):
- 2 new params:
- `{contentEditable: true}` allows to display/add/edit text in regions upon the waveform
- `{removeButton: true}` displays remove button in regions
- New example -- video annotation using `{contentEditable: true}` and `{removeButton: true}`
- Fix iphone silent switch webaudio mute (#2667)
- Respect mute state when changing volume during mute (#2502)
- Proxy HTMLMediaElement's 'waiting' event through MediaElement backend. (#2691)
Expand All @@ -26,10 +31,6 @@ wavesurfer.js changelog
- Fix `barMinHeight` option not setting the minimum bar height properly (#2522)
- Regions plugin:
- Restore support for one drag selection for all channels (#2529)
- 2 new params (#2521):
- `{contentEditable: true}` allows to display/add/edit text in regions upon the waveform
- `{removeButton: true}` displays remove button in regions
- New example -- video annotation using `{contentEditable: true}` and `{removeButton: true}`
- Markers plugin:
- Add support for a context menu event on a marker (#2546)
- Spectrogram plugin: Make labels have position: absolute instead of fixed (#2542)
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,22 @@ If you want to use [the VS Code - Debugger for Chrome](https://github.com/Micros
## Editing documentation
The homepage and documentation files are maintained in the [`gh-pages` branch](https://github.com/wavesurfer-js/wavesurfer.js/tree/gh-pages). Contributions to the documentation are especially welcome.

## Updating the NPM package
When preparing a new release, update the version in the `package.json` and have it merged to master. The new version of the package will be published to NPM automatically via GitHub Actions.
## Releasing a new version
To release a new version and publish it to NPM, follow the steps below.

Switch to the master branch and make sure it's up-to-date
```
git checkout master
git fetch --all; git reset --hard origin/master
```

Run the release script:
```
yarn release
```
This will update the version, generate a changelog, and push everything to a new branch called `release/X.X.X`.

A browser window will open to create a PR from this new branch to the master branch. Once the PR is approved and merged, an automated workflow will kick in and publish a release both on GitHub and NPM.

## Credits

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"test": "karma start karma.conf.js",
"test:chrome": "karma start karma.conf.js --browsers=Chrome --single-run=false",
"prepublishOnly": "not-in-install && npm run build || in-install",
"prepare": "npm run build"
"prepare": "npm run build",
"release": "./scripts/release.sh"
},
"repository": {
"type": "git",
Expand Down
39 changes: 39 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

echo "Before proceeding, please make sure you're on a clean branch with the commits you want to release (typically the master branch)."
echo ''

# Get the last released version from NPM
OLD_VERSION=$(npm show wavesurfer.js version)

# Get the new version from the user
echo "The last version was $OLD_VERSION"
echo "Please type the new version:"
read NEW_VERSION

# Update the CHANGES.md file
echo 'Updating CHANGES.md...'
head -n 3 CHANGES.md > tmp
echo "$NEW_VERSION ($(date '+%d.%m.%Y'))" >> tmp
echo "------------------" >> tmp
git log "$OLD_VERSION"..HEAD --pretty=format:"* %s" >> tmp
echo '' >> tmp
tail -n +3 CHANGES.md >> tmp
cat tmp > CHANGES.md
rm tmp

# Update the version in the package.json file
echo 'Updating package.json...'
sed -i "s/\"version\": \".*\"/\"version\": \"$NEW_VERSION\"/" package.json

# Commit the changes
echo "Pushing the changes to release/$NEW_VERSION"
git add CHANGES.md package.json
git commit -m "Release $NEW_VERSION"
git push origin $(git branch --show-current):release/$NEW_VERSION -f

# Open a pull request via the browser
echo "Opening a pull request for release/$NEW_VERSION"
open "https://github.com/wavesurfer-js/wavesurfer.js/compare/master...release/$NEW_VERSION?expand=1"


0 comments on commit 0f0aa30

Please sign in to comment.