You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name: Create a GitHub releaseon:
push:
jobs:
release:
name: Create a GitHub releaseif: startsWith(github.ref, 'refs/tags/')runs-on: ubuntu-latestpermissions:
contents: writesteps:
- name: Check if tag is a SemVer (pre-)releaserun: | # SemVer regex adapted for bash from: # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string SEMVER_REGEX="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$" if [[ "$GITHUB_REF_NAME" =~ $SEMVER_REGEX ]]; then # If it matches, then it's a SemVer name prereleasePart="${BASH_REMATCH[5]}" # The 5th group is the pre-release part else echo "Version $GITHUB_REF_NAME is not SemVer" 1>&2 exit 1 fi if [[ -n "$prereleasePart" ]]; then # If not empty, then it's a pre-release echo "is_prerelease=true" >> "$GITHUB_ENV" else echo "is_prerelease=false" >> "$GITHUB_ENV" fi
- name: Create a GitHub Releaseuses: softprops/action-gh-release@v2with:
prerelease: ${{ env.is_prerelease }}
Disclaimer: I manually edited this from a more complex setup, renaming a few things here and there for the purposes of leaving a comment here that would hopefully be helpful. I can't guarantee that this would actually work as-is in a GitHub Actions workflow: there might be errors, both in the YAML syntax and at runtime.
Would like an option to to autmatically mark the file as a pre-release if versioned as a semver pre-release. (eg
1.1.0-beta.2
)Don't know whether there exists another way to accomplish this?
The text was updated successfully, but these errors were encountered: