refactor: remove setup-jest
files
#12
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: | |
- next | |
jobs: | |
release_to_npm: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ποΈ | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 20 | |
fetch-tags: false | |
- name: Setup Node version βοΈ | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: https://registry.npmjs.org/ | |
- id: cache-yarn | |
name: Restore cached node modules β»οΈ | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.yarn/cache | |
node_modules | |
key: ${{ inputs.os }}-${{ inputs.node }}-release-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ inputs.os }}-${{ inputs.node }}-release | |
- id: version_check | |
name: Verify new version π | |
run: | | |
PKG_VERSION=$(node -p "require('./package.json').version") | |
PKG_NAME=$(node -p "require('./package.json').name") | |
PUBLISHED_VERSION=$(npm view $PKG_NAME version 2>/dev/null || echo "0.0.0") | |
echo "version=$PKG_VERSION" >> $GITHUB_OUTPUT | |
if [ "$PKG_VERSION" = "$PUBLISHED_VERSION" ]; then | |
echo "is_new_version=false" >> $GITHUB_OUTPUT | |
else | |
echo "is_new_version=true" >> $GITHUB_OUTPUT | |
fi | |
- id: release_type | |
name: Identify release type π | |
if: ${{ steps.version_check.outputs.is_new_version == 'true' }} | |
run: echo "is_latest=$LATEST" >> $GITHUB_OUTPUT | |
env: | |
# Check on current `version` from the step above to decide whether to publish to `latest`/`next` npm tag | |
LATEST: ${{ contains(steps.version_check.outputs.version, '-next') != true && contains(steps.version_check.outputs.version, '-rc') != true }} | |
- id: create_tag | |
name: Create and push tag π | |
if: ${{ steps.version_check.outputs.is_new_version == 'true' }} | |
run: | | |
TAG_NAME="v${{ steps.version_check.outputs.version }}" | |
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT | |
git tag $TAG_NAME | |
git push origin $TAG_NAME | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release π’ | |
if: ${{ steps.version_check.outputs.is_new_version == 'true' }} | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.create_tag.outputs.tag_name }} | |
body: Please refer to [CHANGELOG.md](https://github.com/thymikee/jest-preset-angular/blob/${{ steps.create_tag.outputs.tag_name }}/CHANGELOG.md) for details. | |
draft: false | |
prerelease: ${{ steps.release_type.outputs.is_latest != 'true' }} | |
- name: Install π§ | |
if: ${{ steps.version_check.outputs.is_new_version == 'true' }} | |
run: yarn --immutable | |
- name: Build π¨ | |
if: ${{ steps.version_check.outputs.is_new_version == 'true' }} | |
run: yarn build | |
- name: Publish with latest tag π | |
if: ${{ steps.version_check.outputs.is_new_version == 'true' && steps.release_type.outputs.is_latest == 'true' }} | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Publish with next tag π | |
if: ${{ steps.version_check.outputs.is_new_version == 'true' && steps.release_type.outputs.is_latest != 'true' }} | |
run: npm publish --access public --tag next | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |