Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
run: npm rebuild && npm run prepare --if-present
- name: Test
run: npm test
- name: Check release script
run: bash -n release.sh
- name: Release
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: ./release.sh
Expand Down
24 changes: 11 additions & 13 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#!/bin/bash

VERSION=$(node -p "require('./package.json').version")

git config --local user.email "github@reedsy.com"
git config --local user.name "GitHub Action"
git fetch --tags
set -eo pipefail

VERSION_COUNT=$(git tag --list $VERSION | wc -l)
PACKAGE=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")

if [ $VERSION_COUNT -gt 0 ]
if [ -n "$(npm view "$PACKAGE@$VERSION" version 2> /dev/null)" ]
then
echo "Version $VERSION already deployed."
echo "Version $VERSION already published."
exit 0
else
echo "Deploying version $VERSION"
fi

git tag $VERSION
git push origin refs/tags/$VERSION
echo "Publishing version $VERSION"
npm publish --tag latest

npm publish
if ! git tag "$VERSION" || ! git push origin "refs/tags/$VERSION"
then
echo "Published $VERSION but could not tag it." >&2
fi
Loading