fix: temporarily remove syntax highlights #173
This file contains hidden or 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: Automated Release | |
on: | |
push: | |
branches: [main, next] | |
permissions: | |
contents: write | |
actions: read | |
concurrency: | |
group: release-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
if: | | |
startsWith(github.event.head_commit.message, 'feat') || | |
startsWith(github.event.head_commit.message, 'fix') | |
runs-on: macos-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Bump version and create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -e | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
# Fetch latest semver tag | |
LATEST_TAG=$(git tag -l '[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n 1 || true) | |
LATEST_TAG=$(echo "$LATEST_TAG" | tr -d '[:space:]') | |
CURRENT_VERSION="${LATEST_TAG:-0.0.0}" | |
IFS='.' read -r MAJOR MINOR PATCH <<EOF | |
$CURRENT_VERSION | |
EOF | |
case "$COMMIT_MESSAGE" in | |
feat!*) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; | |
feat:*) MINOR=$((MINOR + 1)); PATCH=0 ;; | |
fix!:*) PATCH=$((PATCH + 1)) ;; | |
fix:*) PATCH=$((PATCH + 1)) ;; | |
esac | |
NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
BRANCH_NAME="${GITHUB_REF_NAME}" | |
if [ "$BRANCH_NAME" = "main" ]; then | |
RELEASE_TAG="$NEW_VERSION" | |
RELEASE_TITLE="Release $NEW_VERSION" | |
IS_PRERELEASE=false | |
else | |
RELEASE_TAG="next-$NEW_VERSION" | |
RELEASE_TITLE="Pre-release next-$NEW_VERSION" | |
IS_PRERELEASE=true | |
fi | |
echo "Bumping version to $RELEASE_TAG" | |
git config user.name "GitHub Actions" | |
git config user.email "actions@github.com" | |
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
git tag -a "$RELEASE_TAG" -m "$RELEASE_TAG" | |
git push origin "$RELEASE_TAG" | |
if [ -n "$LATEST_TAG" ]; then | |
RELEASE_NOTES=$(git log "$LATEST_TAG"..HEAD --pretty=format:"- %s") | |
else | |
RELEASE_NOTES=$(git log --pretty=format:"- %s") | |
fi | |
gh release create "$RELEASE_TAG" \ | |
--title "$RELEASE_TITLE" \ | |
--notes "$RELEASE_NOTES" \ | |
--prerelease="$IS_PRERELEASE" |