Merge pull request #5 from oclif/dependabot/npm_and_yarn/micromatch-4… #30
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
# test | |
name: version, tag and github release | |
on: | |
push: | |
branches: [main] | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
- name: Check if version already exists | |
id: version-check | |
run: | | |
package_version=$(node -p "require('./package.json').version") | |
exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "") | |
if [ -n "$exists" ]; | |
then | |
echo "Version v$package_version already exists" | |
echo "::warning file=package.json,line=1::Version v$package_version already exists - no release will be created. If you want to create a new release, please update the version in package.json and push again." | |
echo "skipped=true" >> $GITHUB_OUTPUT | |
else | |
echo "Version v$package_version does not exist. Creating release..." | |
echo "skipped=false" >> $GITHUB_OUTPUT | |
echo "tag=v$package_version" >> $GITHUB_OUTPUT | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Setup git | |
if: ${{ steps.version-check.outputs.skipped == 'false' }} | |
run: | | |
git config --global user.email ${{ secrets.GH_EMAIL }} | |
git config --global user.name ${{ secrets.GH_USERNAME }} | |
- name: Generate oclif README | |
if: ${{ steps.version-check.outputs.skipped == 'false' }} | |
id: oclif-readme | |
run: | | |
yarn | |
yarn oclif readme | |
if [ -n "$(git status --porcelain)" ]; then | |
git add . | |
git commit -am "chore: update README.md" | |
git push -u origin ${{ github.ref_name }} | |
fi | |
- name: Create Github Release | |
uses: ncipollo/release-action@v1 | |
if: ${{ steps.version-check.outputs.skipped == 'false' }} | |
with: | |
name: ${{ steps.version-check.outputs.tag }} | |
tag: ${{ steps.version-check.outputs.tag }} | |
commit: ${{ github.ref_name }} | |
token: ${{ secrets.GH_TOKEN }} | |
skipIfReleaseExists: true | |
# - name: Get the next version for oclif readme | |
# id: next-version | |
# uses: TriPSs/conventional-changelog-action@v5 | |
# with: | |
# tag-prefix: '' | |
# skip-version-file: true # Do not update the version in the package.json | |
# skip-commit: true # Do not commit the version bump | |
# git-push: false # Do not push to Github | |
# skip-tag: true # Do not tag release | |
# output-file: 'false' # No changelog file | |
# - name: Generate oclif readme | |
# if: ${{ steps.next-version.outputs.skipped == 'false' }} | |
# run: | | |
# yarn | |
# yarn oclif readme --version ${{ steps.next-version.outputs.tag }} | |
# - name: Generate CHANGELOG.md | |
# if: ${{ steps.next-version.outputs.skipped == 'false' }} | |
# id: changelog | |
# uses: TriPSs/conventional-changelog-action@v5 | |
# with: | |
# git-user-name: ${{ secrets.GH_USERNAME }} | |
# git-user-email: ${{ secrets.GH_EMAIL }} | |
# github-token: ${{ secrets.GH_TOKEN }} | |
# # Setting 'release-count' to 0 will keep ALL releases in the change log file (no pruning) | |
# release-count: '0' | |
# output-file: 'CHANGELOG.md' | |
# - name: Create Github Release | |
# uses: ncipollo/release-action@v1 | |
# if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
# with: | |
# name: ${{ steps.changelog.outputs.tag }} | |
# tag: ${{ steps.changelog.outputs.tag }} | |
# commit: ${{ github.ref_name }} | |
# body: ${{ steps.changelog.outputs.clean_changelog }} | |
# token: ${{ secrets.GH_TOKEN }} | |
# skipIfReleaseExists: true |