-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: exit gracefully if not release is needed (#41)
Otherwise `release.yml` will fail needlessly.
- Loading branch information
1 parent
a1b6aa2
commit 1cd7bdb
Showing
1 changed file
with
26 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,27 +13,45 @@ jobs: | |
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: semantic release | ||
|
||
- name: Determine next tag version | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} | ||
run: | | ||
# Run in dry-run mode to determine the next tag version and store it in semantic-release-next-version.txt | ||
npx [email protected] --dry-run | tee semantic-release-next-version.txt | ||
# Run in dry-run mode to determine the next tag version and store it in semantic-release-dry-run.txt | ||
npx [email protected] --dry-run | tee semantic-release-dry-run.txt | ||
if grep -q 'no new version is released' semantic-release-dry-run.txt; then | ||
RELEASE_NEEDED=no | ||
else | ||
RELEASE_NEEDED=yes | ||
fi | ||
echo "RELEASE_NEEDED=$RELEASE_NEEDED" >> $GITHUB_ENV | ||
NEXT_VERSION=$( | ||
cat semantic-release-next-version.txt | \ | ||
cat semantic-release-dry-run.txt | \ | ||
grep -o 'Skip v.* tag creation in dry-run mode' \ | ||
| sed -e 's/^Skip //' | sed -e 's/ tag creation in dry-run mode$//' | ||
) | ||
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV | ||
echo "DEBUG: RELEASE_NEEDED = '$RELEASE_NEEDED' " | ||
echo "DEBUG: Next version is '$NEXT_VERSION'" # Debug version number | ||
if [ -z "$NEXT_VERSION" ]; then | ||
echo "ERROR: Could not determine next version from semantic-release dry-run output." | ||
exit 1 | ||
fi | ||
- name: Fail if release is needed but version number is not set | ||
if: env.RELEASE_NEEDED == 'yes' && env.NEXT_VERSION == '' | ||
run: | | ||
echo "ERROR: Could not determine next version from semantic-release dry-run output." | ||
exit 1 | ||
- name: Release to both GitHub and npm | ||
if: env.NEXT_VERSION | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} | ||
run: | | ||
# Hardcode the next tag version in the atlas script | ||
sed -i -e "s/_ATLAS_VERSION=.*/_ATLAS_VERSION=\"$NEXT_VERSION\" # Tagged by release.yml/" atlas | ||
|