diff --git a/.github/create-release.yml b/.github/create-release.yml new file mode 100644 index 00000000..fb54770a --- /dev/null +++ b/.github/create-release.yml @@ -0,0 +1,42 @@ +name: Deploy Production + +on: + workflow_dispatch: + inputs: + version: + type: choice + description: Select version bump + options: + - major + - minor + - patch + +jobs: + production: + runs-on: ubuntu-latest + permissions: + contents: write + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + cache: "yarn" + node-version-file: ".tool-versions" + - name: Setup build dependencies + run: make deps + - name: Configure Git user + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Build + run: | + yarn run release + git add dist/ + - name: Bump Version + run: | + bumpver update --${{ github.event.inputs.version }} + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 01cb0a95..9fb01fff 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ dist/mercury_test.js dist/mercury_test.js.map dist/mercury_test.web.js tmp/artifacts +tmp/CHANGELOG.md test-output.json .yarnrc.yml **/.DS_Store diff --git a/Makefile b/Makefile index 96e4047c..304df3bd 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,22 @@ SHELL :=/usr/bin/env bash +CHANGELOG=CHANGELOG.md +CHANGELOG_TMP=tmp/$(CHANGELOG) + .PHONY: deps deps: ## Install bumpver pip install bumpver==2024.1130 + +$(CHANGELOG_TMP): + mkdir -p tmp + echo -e "# Mercury Parser Changelog\n" > $(CHANGELOG_TMP) + echo $(now) + echo -e "### $(BUMPVER_NEW_VERSION) ($$(date '+%b %d, %Y'))\n" >> $(CHANGELOG_TMP) + yarn run --silent changelog-maker --format=markdown >> $(CHANGELOG_TMP) + cat $(CHANGELOG) | sed 1d >> $(CHANGELOG_TMP) + cp $(CHANGELOG_TMP) $(CHANGELOG) + +$(CHANGELOG): $(CHANGELOG_TMP) + +.PHONY: changelog +changelog: $(CHANGELOG) diff --git a/bumpver.toml b/bumpver.toml new file mode 100644 index 00000000..0bc138ff --- /dev/null +++ b/bumpver.toml @@ -0,0 +1,15 @@ +[bumpver] +current_version = "2.2.3" +version_pattern = "[MAJOR].[MINOR].[PATCH]" +commit_message = "bump version {old_version} -> {new_version}" +tag_message = "{new_version}" +tag_scope = "default" +pre_commit_hook = "scripts/update-changelog" +post_commit_hook = "" +commit = true +tag = true +push = false + +[bumpver.file_patterns] +"package.json" = ['"version": "{version}"'] +"bumpver.toml" = ['current_version = "{version}"'] diff --git a/package.json b/package.json index d98591a3..1084b7a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jocmp/mercury-parser", - "version": "2.2.3-dev", + "version": "2.2.3", "description": "Mercury Parser transforms web pages into clean text. Publishers and programmers use it to make the web make sense, and readers use it to read any web article comfortably.", "author": "jocmp ", "homepage": "https://github.com/jocmp/mercury-parser", diff --git a/scripts/update-changelog b/scripts/update-changelog new file mode 100755 index 00000000..f1e18515 --- /dev/null +++ b/scripts/update-changelog @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +make changelog +git add CHANGELOG.md