From 3e06c5fd6690e0e27f45aa12cc1b4e29ec428d31 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 10 Dec 2022 11:59:40 +0100 Subject: [PATCH] chore: add release workflow (#1185) --- .github/workflows/release.yml | 135 +++++++++++++++++++++++++ .github/workflows/update_changelog.yml | 42 -------- cliff-release.toml | 66 ++++++++++++ cliff.toml | 26 +++-- remote/.htaccess | 8 ++ remote/config.json | 7 ++ src/store/actions.ts | 1 - 7 files changed, 228 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/update_changelog.yml create mode 100644 cliff-release.toml create mode 100644 remote/.htaccess create mode 100644 remote/config.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..6d4ea2b4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,135 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + type: string + description: New version number in X.Y.Z + required: true + +jobs: + push-version-number: + runs-on: ubuntu-latest + steps: + - name: Clone develop repository + uses: actions/checkout@v3 + with: + token: ${{ secrets.PAT }} + ref: 'develop' + + - name: Push version number + shell: bash + run: | + npm version --no-git-tag-version ${{ github.event.inputs.version }} + + - name: git add & commit & push + uses: EndBug/add-and-commit@v9 + with: + add: 'package.json package-lock.json' + default_author: github_actions + message: 'chore: push version number to v${{ github.event.inputs.version }}' + tag: 'v${{ github.event.inputs.version }}' + push: true + + update-master-branch: + needs: ['push-version-number'] + runs-on: ubuntu-latest + steps: + - uses: everlytic/branch-merge@1.1.5 + with: + github_token: ${{ github.token }} + source_ref: 'develop' + target_branch: 'master' + commit_message_template: '[Automated] Merged {source_ref} into target {target_branch}' + + release: + needs: ['update-master-branch'] + runs-on: ubuntu-latest + steps: + - name: Fetch repo + uses: actions/checkout@v3 + with: + ref: 'master' + fetch-depth: 0 + + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Move build out of dist + shell: bash + run: mv ./dist/mainsail.zip ./mainsail.zip + + - name: Generate a changelog + uses: orhun/git-cliff-action@v1 + id: generate-changelog + with: + config: ./cliff-release.toml + args: -vv --latest --strip header + env: + output: CHANGES.md + + - name: Create release and upload build + uses: softprops/action-gh-release@v1 + id: create-release + with: + name: v${{ github.event.inputs.version }} + tag_name: v${{ github.event.inputs.version }} + token: ${{ secrets.GITHUB_TOKEN }} + files: ./mainsail.zip + body: ${{ steps.generate-changelog.outputs.content }} + + - name: Copy remote configs to dist + shell: bash + run: cp ./remote/* ./dist/ + + - name: Upload to remote server + uses: SamKirkland/FTP-Deploy-Action@4.3.3 + with: + server: ${{ secrets.REMOTEHOST }} + username: ${{ secrets.REMOTEUSER }} + password: ${{ secrets.REMOTEPASSWORD }} + dangerous-clean-slate: true + local-dir: ./dist/ + + update-changelog: + needs: ['release'] + name: Generate changelog + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: 'develop' + token: ${{ secrets.PAT }} + fetch-depth: 0 + + - name: Get latest tag + id: latest_tag + shell: bash + run: | + echo "TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_OUTPUT + - name: Generate a changelog + uses: orhun/git-cliff-action@v1 + id: git-cliff + with: + config: cliff.toml + args: v0.0.4..${{ steps.latest_tag.outputs.TAG_NAME }} + env: + OUTPUT: ${{ github.workspace }}/CHANGELOG.md + + - name: Show CHANGELOG + run: | + cat CHANGELOG.md + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 'chore(changelog): update changelog' + file_pattern: CHANGELOG.md diff --git a/.github/workflows/update_changelog.yml b/.github/workflows/update_changelog.yml deleted file mode 100644 index 13f25ceb..00000000 --- a/.github/workflows/update_changelog.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Update changelog - -on: - # Update the changelog after pushing a new tag - push: - tags: - - '*' - - # Update the changelog by invoking this workflow manually - workflow_dispatch: - -jobs: - changelog: - name: Generate changelog - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Get latest tag - run: | - echo "::set-output name=TAG_NAME::$(git describe --tags $(git rev-list --tags --max-count=1))" - id: latest_tag - - name: Generate a changelog - uses: orhun/git-cliff-action@v1 - id: git-cliff - with: - config: cliff.toml - args: v0.0.4..${{ steps.latest_tag.outputs.TAG_NAME }} - env: - OUTPUT: CHANGELOG.md - - - name: show CHANGELOG - run: | - cat CHANGELOG.md - - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: 'chore(changelog): update changelog' - file_pattern: CHANGELOG.md - branch: develop diff --git a/cliff-release.toml b/cliff-release.toml new file mode 100644 index 00000000..67376463 --- /dev/null +++ b/cliff-release.toml @@ -0,0 +1,66 @@ +# configuration file for git-cliff (0.1.0) + +[changelog] +# changelog header +header = """ +# What's Changed +""" +# template for the changelog body +# https://tera.netlify.app/docs/#introduction +body = """ +{% for group, commits in commits | group_by(attribute="group") %}\ + ### {{ group | split(pat="$") | last | upper_first }} + {% for commit in commits + | filter(attribute="scope") + | sort(attribute="scope") %} + - **{{commit.scope}}**: {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }})\ + {%- if commit.breaking %} + {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} + {%- endif -%} + + {%- endfor -%} + {%- for commit in commits %} + {%- if commit.scope -%} + {% else -%} + {% raw %}\n{% endraw %}\ + - {{ commit.message | upper_first | trim }} | [{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }})\ + {%- if commit.breaking %} + {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} + {%- endif -%} + + {% endif -%} + {% endfor -%} + {% raw %}\n{% endraw %} +{% endfor %}\n\ +""" +# remove the leading and trailing whitespaces from the template +trim = true +# changelog footer +footer = """ +""" + +[git] +# allow only conventional commits +# https://www.conventionalcommits.org +conventional_commits = true +filter_unconventional = true +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^docs\\(changelog\\):", group = "Changelog", skip = true}, # Old redundant commits + { message = "^feat(\\(.*\\))?:", group = "1$Features"}, + { message = "^feature(\\(.*\\))?:", group = "1$Features"}, + { message = "^fix(\\(.*\\))?:", group = "2$Bug Fixes and Improvements"}, + { message = "^docs(\\(.*\\))?:", group = "7$Documentation"}, + { message = "^perf(\\(.*\\))?:", group = "3$Performance"}, + { message = "^refactor(\\(.*\\))?:", group = "4$Refactor"}, + { message = "^style(\\(.*\\))?:", group = "5$Styling"}, + { message = "^test(\\(.*\\))?:", group = "9$Other"}, + { message = "^locale(\\(.*\\))?:", group = "6$Localization"}, + { message = "^chore(\\(.*\\))?:", group = "9$Other"}, + { body = ".*security", group = "Security"}, +] +# filter out the commits that are not matched by commit parsers +filter_commits = true +ignore_tags="v*-(beta|rc)*" +# glob pattern for matching git tags +tag_pattern = "v[0-9]*" diff --git a/cliff.toml b/cliff.toml index f4e8ed12..119c6712 100644 --- a/cliff.toml +++ b/cliff.toml @@ -17,7 +17,7 @@ body = """ ## [unreleased] {% endif %}\ {% for group, commits in commits | group_by(attribute="group") %}\ - ### {{ group | upper_first }} + ### {{ group | split(pat="$") | last | upper_first }} {% for commit in commits | filter(attribute="scope") | sort(attribute="scope") %} @@ -25,7 +25,6 @@ body = """ {%- if commit.breaking %} {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} {%- endif -%} - {%- endfor -%} {%- for commit in commits %} {%- if commit.scope -%} @@ -35,7 +34,6 @@ body = """ {%- if commit.breaking %} {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} {%- endif -%} - {% endif -%} {% endfor -%} {% raw %}\n{% endraw %} @@ -55,16 +53,16 @@ filter_unconventional = false # regex for parsing and grouping commits commit_parsers = [ { message = "^docs\\(changelog\\):", group = "Changelog", skip = true}, # Old redundant commits - { message = "^feat(\\(.*\\))?:", group = "Features"}, - { message = "^feature(\\(.*\\))?:", group = "Features"}, - { message = "^fix(\\(.*\\))?:", group = "Bug Fixes"}, - { message = "^docs(\\(.*\\))?:", group = "Documentation"}, - { message = "^perf(\\(.*\\))?:", group = "Performance"}, - { message = "^refactor(\\(.*\\))?:", group = "Refactor"}, - { message = "^style(\\(.*\\))?:", group = "Styling"}, - { message = "^test(\\(.*\\))?:", group = "Testing"}, - { message = "^locale(\\(.*\\))?:", group = "Localization"}, - { message = "^chore(\\(.*\\))?:", group = "Miscellaneous Tasks", skip = true}, # chore tasks are not relevant for the changelog + { message = "^feat(\\(.*\\))?:", group = "1$Features"}, + { message = "^feature(\\(.*\\))?:", group = "1$Features"}, + { message = "^fix(\\(.*\\))?:", group = "2$Bug Fixes and Improvements"}, + { message = "^docs(\\(.*\\))?:", group = "7$Documentation"}, + { message = "^perf(\\(.*\\))?:", group = "3$Performance"}, + { message = "^refactor(\\(.*\\))?:", group = "4$Refactor"}, + { message = "^style(\\(.*\\))?:", group = "5$Styling"}, + { message = "^test(\\(.*\\))?:", group = "9$Other"}, + { message = "^locale(\\(.*\\))?:", group = "6$Localization"}, + { message = "^chore(\\(.*\\))?:", group = "9$Other"}, { body = ".*security", group = "Security"}, { message = "release v2.1.2", group = "Release"}, # workaround for v2.1.2 release ] @@ -72,4 +70,4 @@ commit_parsers = [ filter_commits = true ignore_tags="v*-(beta|rc)*" # glob pattern for matching git tags -tag_pattern = "v[0-9]*" +tag_pattern = "v[0-9]*" \ No newline at end of file diff --git a/remote/.htaccess b/remote/.htaccess new file mode 100644 index 00000000..b0e00a12 --- /dev/null +++ b/remote/.htaccess @@ -0,0 +1,8 @@ + + RewriteEngine On + RewriteBase / + RewriteRule ^index\.html$ - [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule . /index.html [L] + \ No newline at end of file diff --git a/remote/config.json b/remote/config.json new file mode 100644 index 00000000..1ac52bb3 --- /dev/null +++ b/remote/config.json @@ -0,0 +1,7 @@ +{ + "defaultLocale": "en", + "hostname": null, + "port": null, + "instancesDB": "browser", + "instances": [] +} diff --git a/src/store/actions.ts b/src/store/actions.ts index 105b7be7..c43520e9 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -32,7 +32,6 @@ export const actions: ActionTree = { importConfigJson({ commit }, payload: ConfigJson) { type RootStateInstancesDbType = 'moonraker' | 'browser' | 'json' let instancesDB: RootStateInstancesDbType = payload.instancesDB ?? 'moonraker' - if (document.location.hostname === 'my.mainsail.xyz') instancesDB = 'browser' if (import.meta.env.VUE_APP_INSTANCES_DB) instancesDB = import.meta.env.VUE_APP_INSTANCES_DB as RootStateInstancesDbType