Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
"husky",
"jest-junit",
"json-schema",
"npm-check-updates",
"prettier",
"standard-version",
"ts-jest",
"typescript",
"lcov",
Expand Down
47 changes: 42 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
contents: write
outputs:
latest_commit: ${{ steps.git_remote.outputs.latest_commit }}
tag_exists: ${{ steps.check_tag.outputs.tag_exists }}
env:
CI: "true"
steps:
Expand All @@ -24,13 +25,49 @@ jobs:
git config user.email "github-actions@github.com"
- name: Install dependencies
run: yarn install --check-files --frozen-lockfile
- name: release
run: npm run release
- name: Determine version
id: version
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
LATEST_VERSION=${LATEST_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION"
NEXT_PATCH=$((PATCH + 1))
NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}"
echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "tag=v$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "Next version: $NEXT_VERSION"
- name: Check if tag already exists
id: check_tag
run: |
if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "tag_exists=true" >> $GITHUB_OUTPUT
echo "Tag ${{ steps.version.outputs.tag }} already exists, skipping release"
else
echo "tag_exists=false" >> $GITHUB_OUTPUT
fi
- name: Bump version
if: steps.check_tag.outputs.tag_exists == 'false'
run: npm version ${{ steps.version.outputs.version }} --no-git-tag-version
- name: Build
if: steps.check_tag.outputs.tag_exists == 'false'
run: npm run build
- name: Generate changelog
if: steps.check_tag.outputs.tag_exists == 'false'
run: |
mkdir -p dist
echo "${{ steps.version.outputs.tag }}" > dist/releasetag.txt
echo "${{ steps.version.outputs.version }}" > dist/version.txt
git log $(git describe --tags --abbrev=0 2>/dev/null || echo "")..HEAD --pretty=format:"* %s (%h)" > dist/changelog.md
- name: Tag release
if: steps.check_tag.outputs.tag_exists == 'false'
run: |
git tag -a ${{ steps.version.outputs.tag }} -m "chore(release): ${{ steps.version.outputs.version }}"
git push origin ${{ steps.version.outputs.tag }}
- name: Check for new commits
id: git_remote
run: echo "latest_commit=$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" >> $GITHUB_OUTPUT
- name: Upload artifact
if: ${{ steps.git_remote.outputs.latest_commit == github.sha }}
if: steps.check_tag.outputs.tag_exists == 'false' && steps.git_remote.outputs.latest_commit == github.sha
uses: actions/upload-artifact@v4
with:
name: build-artifact
Expand All @@ -41,7 +78,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
if: needs.release.outputs.latest_commit == github.sha
if: needs.release.outputs.tag_exists == 'false' && needs.release.outputs.latest_commit == github.sha
steps:
- uses: actions/setup-node@v4
- name: Download build artifacts
Expand All @@ -61,7 +98,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
if: needs.release.outputs.latest_commit == github.sha
if: needs.release.outputs.tag_exists == 'false' && needs.release.outputs.latest_commit == github.sha
steps:
- uses: actions/setup-node@v4
- name: Download build artifacts
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"eslint:json": "eslint --no-eslintrc --no-error-on-unmatched-pattern --config .eslintrc-json.json --ext .json .",
"package": "mkdir -p dist/js && npm pack --pack-destination dist/js",
"prepare": "husky install",
"release": "rm -fr dist && standard-version && npm run build",
"spellcheck": "cspell lint --gitignore --dot --show-suggestions -e \".git/**\" \"**\"",
"test": "jest --passWithNoTests --all --updateSnapshot && npm run eslint && npm run spellcheck && npm run eslint:json",
"test:update": "jest --updateSnapshot",
Expand Down Expand Up @@ -51,7 +50,6 @@
"jest-junit": "^13",
"json-schema": "^0.4.0",
"prettier": "^2.6.2",
"standard-version": "^9",
"ts-jest": "^27",
"typescript": "^4.6.3"
},
Expand Down
Loading
Loading