Merge pull request #4 from vadimavdeev/api-reference #1
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
name: Release | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
publish-npm: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: "yarn" | |
registry-url: "https://registry.npmjs.org" | |
- uses: ./.github/workflows/yarn | |
- name: Build | |
run: yarn build | |
- name: Test | |
run: yarn test | |
- name: Extract version | |
id: version | |
run: | | |
OLD_VERSION=$(npm show react-voicemail-player version) | |
NEW_VERSION=$(node -p 'require("./package.json").version') | |
if [ $NEW_VERSION != $OLD_VERSION ]; then | |
echo "New version $NEW_VERSION detected" | |
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
git log "$OLD_VERSION"..HEAD --pretty=format:"* %s" > TEMP_CHANGELOG.md | |
else | |
echo "Version $OLD_VERSION hasn't changed, skipping the release" | |
fi | |
- name: Create Git Tag | |
if: ${{ steps.version.outputs.version }} | |
run: git tag $NEW_VERSION && git push --tags | |
env: | |
NEW_VERSION: ${{ steps.version.outputs.version }} | |
- name: Create GitHub Release | |
if: ${{ steps.version.outputs.version }} | |
uses: softprops/action-gh-release@v1 | |
id: create_release | |
with: | |
draft: false | |
prerelease: false | |
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 | |
if: ${{ steps.version.outputs.version }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npm publish |