Skip to content

Release

Release #12

Workflow file for this run

name: Release
on:
# Allows to trigger workflow manually
workflow_dispatch:
jobs:
ensure_version_changed:
name: Ensure that version was changed
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if version was changed
id: check_version
run: |
NEW_PACKAGE_VERSION=$(node -pe 'require("./package.json").version')
echo "$NEW_PACKAGE_VERSION"
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latestTag
OLD_PACKAGE_VERSION=$(node -pe 'require("./package.json").version')
echo "$OLD_PACKAGE_VERSION"
if [ $NEW_PACKAGE_VERSION != $OLD_PACKAGE_VERSION ]; then
echo "Version was changed"
echo "version=$NEW_PACKAGE_VERSION" >> $GITHUB_OUTPUT
fi
build:
needs: [ensure_version_changed]
if: ${{ needs.ensure_version_changed.outputs.version }}
uses: ./.github/workflows/build.yaml
secrets: inherit
with:
should_pack: true
publish:
runs-on: ubuntu-latest
needs: [build]
if: ${{ needs.ensure_version_changed.outputs.version }}
name: Publish to npm
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ukorvl-react-on-screen-${{ needs.ensure_version_changed.outputs.version }}
- name: Publish
run: |
npm config set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_PUBLISH_TOKEN }}
npm publish --access public ukorvl-react-on-screen-${{ needs.ensure_version_changed.outputs.version }}.tgz
tag:
runs-on: ubuntu-latest
needs: [publish]
if: ${{ needs.ensure_version_changed.outputs.version }}
name: Tag
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Tag new version
run: git tag v${{ needs.ensure_version_changed.outputs.version }}
- name: Push tags
uses: ad-m/github-push-action@master
with:
tags: true
release:
runs-on: ubuntu-latest
needs: [tag]
if: ${{ needs.ensure_version_changed.outputs.version }}
name: Create release
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
tag: v${{ needs.ensure_version_changed.outputs.version }}
name: Release ${{ needs.ensure_version_changed.outputs.version }}