Skip to content

Commit

Permalink
Have github-script guards throw instead of silently failing
Browse files Browse the repository at this point in the history
  • Loading branch information
AJGranowski committed Sep 29, 2024
1 parent a540f46 commit a8a040e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,24 @@ jobs:
with:
script: |
const latestReleaseTag = process.env.LATEST_RELEASE_TAG;
if (latestReleaseTag.length === 0) {
throw new Error("LATEST_RELEASE_TAG is empty!");
}
if (latestReleaseTag.length > 0) {
const incrementReleaseTag = latestReleaseTag.replace(/(\d+)([^\.]*)$/, (_, x, y) => (Number(x) + 1) + y);
const incrementReleaseTag = latestReleaseTag.replace(/(\d+)([^\.]*)$/, (_, x, y) => (Number(x) + 1) + y);
if (latestReleaseTag === incrementReleaseTag) {
throw new Error("Tag increment failed! (proposed tag matches LATEST_RELEASE_TAG)");
}
if (incrementReleaseTag.length >= latestReleaseTag.length && latestReleaseTag !== incrementReleaseTag) {
return incrementReleaseTag;
}
if (incrementReleaseTag.length < latestReleaseTag.length) {
throw new Error(`Tag increment failed! (proposed tag ${incrementReleaseTag} is shorter than ${latestReleaseTag}`);
}
return incrementReleaseTag;
- name: Tag Release
env:
NEW_RELEASE_TAG: ${{ fromJson(steps.increment-tag.outputs.result) }}
if: ${{ env.LATEST_RELEASE_TAG != '' && env.LATEST_RELEASE_TAG != '""' }}
run: |
git tag "$NEW_RELEASE_TAG";
git push origin tag "$NEW_RELEASE_TAG";
Expand Down
1 change: 0 additions & 1 deletion make-release
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh
set -euC;
#test6

RELEASE_DIR="release/";

Expand Down

0 comments on commit a8a040e

Please sign in to comment.