From 1f05d73ac43b101ef92d359996eb97d5ffa99106 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Tue, 24 Sep 2024 10:49:34 +0200 Subject: [PATCH 01/15] chore: enhance CHANGELOG.md generation --- .github/actions/build-release/action.yml | 76 ++++++++ .github/workflows/changelog.yml | 98 ++++++++++ bin/download_github_releases.py | 3 + cliff.toml | 91 +++++++++ package-lock.json | 236 +++++++++++++++++++++++ package.json | 19 +- 6 files changed, 515 insertions(+), 8 deletions(-) create mode 100644 .github/actions/build-release/action.yml create mode 100644 .github/workflows/changelog.yml create mode 100644 cliff.toml diff --git a/.github/actions/build-release/action.yml b/.github/actions/build-release/action.yml new file mode 100644 index 000000000..d65b3b1a9 --- /dev/null +++ b/.github/actions/build-release/action.yml @@ -0,0 +1,76 @@ +name: "Build a release" +description: "Create the dist files for a specific version" + +inputs: + tag: + description: 'The tag we want to create the release for' + required: true + # @FIX: this should not be required? + commit_sha: + description: 'The commit of the tag' + required: true + encryption_key: + description: 'The key used to encypt the detailed processes' + required: true + private_ssh_key: + description: 'The private ssh key used to clone the detailed impacts' + required: true + ecobalyse_data_dir: + description: 'The path to the ecobalyse dir containing the detailed impacts' + required: false + default: "./ecobalyse-private" +outputs: + dist-archive: + description: "Dist archive file path" + value: ${{ steps.create-dist-archive.outputs.dist-archive }} + + +runs: + using: "composite" + steps: + + - uses: actions/setup-node@v4 + with: + node-version: "20.x" + cache: 'npm' + + - name: Install Node dependencies + shell: bash + run: npm ci --prefer-offline --no-audit + + - name: Clone the detailed impacts + shell: bash + run: | + eval `ssh-agent -s` + ssh-add - <<< '${{ inputs.private_ssh_key }}' + git clone git@github.com:MTES-MCT/ecobalyse-private.git + + - name: Build app + shell: bash + env: + # Specify the created SHA to correctly update version.json + # @FIX: this should not be requiered when creating a tagged version + SOURCE_VERSION: ${{ inputs.commit_sha }} + TAG: ${{ inputs.tag }} + ECOBALYSE_DATA_DIR: ${{ inputs.ecobalyse_data_dir }} + run: | + npm run build:standalone-app + + - name: Encrypt the impacts files + shell: bash + env: + ENCRYPTION_KEY: ${{ inputs.encryption_key }} + ECOBALYSE_DATA_DIR: ${{ inputs.ecobalyse_data_dir }} + run : | + # We include the encrypted detailed processes with the dist + # so that people with the encryption key could later on use the app with the exact + # files it was using on production + npm run encrypt $ECOBALYSE_DATA_DIR/data/textile/processes_impacts.json dist/processes_impacts_textile.json.enc + npm run encrypt $ECOBALYSE_DATA_DIR/data/food/processes_impacts.json dist/processes_impacts_food.json.enc + + - name: Generate dist archive + shell: bash + id: create-dist-archive + run: | + tar czvf ${{ inputs.tag }}-dist.tar.gz dist + echo "dist-archive=${{ inputs.tag }}-dist.tar.gz" >> $GITHUB_OUTPUT diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 000000000..fb1860dab --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,98 @@ +name: Generate changelog + +on: + push: + branches: [ master, staging ] + pull_request: + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + changelog: + name: Generate changelog + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Generate the full changelog + uses: orhun/git-cliff-action@v4 + id: git-cliff + with: + config: cliff.toml + args: --verbose --exclude-path "data/" --bump + env: + OUTPUT: CHANGELOG-cliff.md + + - name: Generate latest changes + uses: orhun/git-cliff-action@v4 + id: git-cliff-latest + with: + config: cliff.toml + args: --verbose --exclude-path "data/" --bump --unreleased + + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v7 + with: + add-paths: | + CHANGELOG-cliff.md + base: master + commit-message: 'chore: update changelog for ${{ steps.git-cliff.outputs.version }}' + signoff: false + branch: chore/update-changelog-${{ steps.git-cliff.outputs.version }} + delete-branch: true + title: 'chore(release): release ${{ steps.git-cliff.outputs.version }}' + body: ${{ steps.git-cliff-latest.outputs.content }} + labels: | + pending-release + automated pr + + + # - name: Commit the changelog + # run: | + # git checkout ${{ steps.extract_branch.outputs.branch }} + # git config user.name 'github-actions[bot]' + # git config user.email 'github-actions[bot]@users.noreply.github.com' + # set +e + # git add CHANGELOG-cliff.md + # git commit -m "Update changelog" + # git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git ${{ steps.extract_branch.outputs.branch }} + # + # - name: Tag the next version + # run: | + # git checkout ${{ steps.extract_branch.outputs.branch }} + # git config user.name 'github-actions[bot]' + # git config user.email 'github-actions[bot]@users.noreply.github.com' + # set +e + # git tag -f ${{ steps.git-cliff.outputs.version }}-cliff-test + # git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git ${{ steps.git-cliff.outputs.version }}-cliff-test + # + # - name: Create dist archive + # uses: ./.github/actions/build-release + # id: create-dist-archive + # with: + # tag: ${{ steps.git-cliff.outputs.version }}-cliff-test + # commit_sha: ${{ github.event.pull_request.head.sha }} + # encryption_key: ${{ secrets.ENCRYPTION_KEY }} + # private_ssh_key: ${{ secrets.PRIVATE_SSH_KEY }} + # + # + # - name: Upload the release + # uses: svenstaro/upload-release-action@v2 + # with: + # file: ${{ steps.create-dist-archive.outputs.dist-archive}} + # repo_token: ${{ secrets.GITHUB_TOKEN }} + # tag: ${{ steps.git-cliff.outputs.version }}-cliff-test + # body: ${{ steps.git-cliff-latest.outputs.content }} + # draft: true diff --git a/bin/download_github_releases.py b/bin/download_github_releases.py index 333a8633a..3a9aa2b6e 100755 --- a/bin/download_github_releases.py +++ b/bin/download_github_releases.py @@ -81,6 +81,9 @@ def download_file(url, destination_directory=None): for asset in release.assets: if "-dist.tar.gz" in asset.browser_download_url: + logger.info( + f"Downloading {asset.browser_download_url} to {args.destination_directory}." + ) file_path = download_file( asset.browser_download_url, args.destination_directory ) diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 000000000..89335662c --- /dev/null +++ b/cliff.toml @@ -0,0 +1,91 @@ +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +[changelog] +# template for the changelog header +header = """ +# Changelog\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ + {% if previous.version %} + ## [{{ version | trim_start_matches(pat="v") }}](https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}/compare/{{ previous.version }}..{{ version }}) ({{ timestamp | date(format="%Y-%m-%d") }}) + + {% else %} + ## {{ version | trim_start_matches(pat="v") }} ({{ timestamp | date(format="%Y-%m-%d") }}) + {% endif %} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }}\ + {% endfor %} +{% endfor %}\n +""" +# template for the changelog footer +footer = """ + +""" +# remove the leading and trailing s +trim = true +# postprocessors +postprocessors = [ + { pattern = '', replace = "https://github.com/MTES-MCT/ecobalyse" }, # replace repository URL +] +# render body even when there are no releases to process +# render_always = true +# output file path +# output = "test.md" + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # Replace issue numbers + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, + # Check spelling of the commit with https://github.com/crate-ci/typos + # If the spelling is incorrect, it will be automatically fixed. + #{ pattern = '.*', replace_command = 'typos --write-changes -' }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "๐Ÿš€ Features" }, + { message = "^fix", group = "๐Ÿ› Bug Fixes" }, + { message = "^doc", group = "๐Ÿ“š Documentation" }, + { message = "^perf", group = "โšก Performance" }, + { message = "^refactor", group = "๐Ÿšœ Refactor" }, + { message = "^style", group = "๐ŸŽจ Styling" }, + { message = "^test", group = "๐Ÿงช Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|^ci", group = "โš™๏ธ Miscellaneous Tasks" }, + { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, + { message = "^revert", group = "โ—€๏ธ Revert" }, +] +# filter out the commits that are not matched by commit parsers +filter_commits = false +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" + +[remote.github] +owner = "MTES-MCT" +repo = "ecobalyse" diff --git a/package-lock.json b/package-lock.json index edb78c619..c2747a475 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "elm-json": "^0.2.13", "elm-review": "^2.12.0", "elm-test": "0.19.1-revision12", + "git-cliff": "^2.6.0", "highcharts": "^11.4.8", "jest": "^29.7.0", "nodemon": "^3.1.4", @@ -7516,6 +7517,241 @@ "assert-plus": "^1.0.0" } }, + "node_modules/git-cliff": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/git-cliff/-/git-cliff-2.6.0.tgz", + "integrity": "sha512-ipMTSjMLjJN0z5AAWUvZJLBYISwu5NvmdrrXmsqwrJ1QXhOgsWOXobft86YH6JJVkKuyh/M4gdhNnAS0H4ldkw==", + "dev": true, + "dependencies": { + "execa": "^8.0.1" + }, + "bin": { + "git-cliff": "lib/cli/cli.js" + }, + "engines": { + "node": ">=18.19 || >=20.6 || >=21" + }, + "optionalDependencies": { + "git-cliff-darwin-arm64": "2.6.0", + "git-cliff-darwin-x64": "2.6.0", + "git-cliff-linux-arm64": "2.6.0", + "git-cliff-linux-x64": "2.6.0", + "git-cliff-windows-arm64": "2.6.0", + "git-cliff-windows-x64": "2.6.0" + } + }, + "node_modules/git-cliff-darwin-arm64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/git-cliff-darwin-arm64/-/git-cliff-darwin-arm64-2.6.0.tgz", + "integrity": "sha512-WdBQmeLKDjJWl/Y6djgwqEUh8eYTJ5ljLea2M8qDhlEBMoC9Ew3VcRmdfTy2fSIxm7WBZm9T6ukkQj4vCv099Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/git-cliff-darwin-x64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/git-cliff-darwin-x64/-/git-cliff-darwin-x64-2.6.0.tgz", + "integrity": "sha512-Zvio86pLAbFGI5khYtVloecKxOac9JV9gL8MR8Eb+1hsliH+LY6MGCzy7zsrDCWEJ9+nH5qfMB24UwABsZhbMg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/git-cliff-linux-arm64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/git-cliff-linux-arm64/-/git-cliff-linux-arm64-2.6.0.tgz", + "integrity": "sha512-FdeulZysE/JFhHmCKnNqXUnOexC4Zg+AloD7DBaiTP5Af2dpVLbV0upjFj2GfQE/x0eGhZH5BqZM5uY6ANuMFQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/git-cliff-linux-x64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/git-cliff-linux-x64/-/git-cliff-linux-x64-2.6.0.tgz", + "integrity": "sha512-lQDjcT1ieJZaC6ULvWcG/0s3+RgItnEsNSD37Xwh/p7HWaz7FZaWrkVySgWSsDahE0GdYnR8v5hs1C1plT2d6w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/git-cliff-windows-arm64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/git-cliff-windows-arm64/-/git-cliff-windows-arm64-2.6.0.tgz", + "integrity": "sha512-xREKhwIKJMZvUzU0nsu0pLt1LMMdWn3367OZoJTy1RyEzqAFpOZXdejuD0GSFCN/t9QgyDJWURQKFekyfKwYSg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/git-cliff-windows-x64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/git-cliff-windows-x64/-/git-cliff-windows-x64-2.6.0.tgz", + "integrity": "sha512-wFnK2cizOrxpPZT4IHmSnUK0YQUuLuI4XZAJHepV4hU4GJWi6q1bIZGoQapRtfZ82bSEF+4EIstoDDoWVwmLGw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/git-cliff/node_modules/execa": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/git-cliff/node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "dev": true, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/git-cliff/node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "dev": true, + "engines": { + "node": ">=16.17.0" + } + }, + "node_modules/git-cliff/node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/git-cliff/node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/git-cliff/node_modules/npm-run-path": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", + "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", + "dev": true, + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/git-cliff/node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dev": true, + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/git-cliff/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/git-cliff/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/git-cliff/node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/glob": { "version": "10.4.5", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", diff --git a/package.json b/package.json index 17a628a57..d89b5ecc4 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,8 @@ "build": "npm run server:build && rimraf dist && npm run build:init && parcel build index.html --public-url ./", "build:init": "./bin/update-version.sh && mkdir -p dist && cp -r public/* dist/ && npm run db:build", "build:standalone-app": "npm run build && npm run server:build && cp server-app.js dist/ && cp openapi.yaml dist/", + "changelog:generate": "git-cliff -o CHANGELOG-cliff.md --exclude-path 'data/'", + "changelog:generate:bump": "npm run changelog:generate -- --bump", "decrypt": "./bin/decrypt", "encrypt": "./bin/encrypt", "db:build": "./bin/build-db && npm run db:check", @@ -65,25 +67,26 @@ }, "devDependencies": { "@apidevtools/swagger-cli": "^4.0.4", + "@parcel/transformer-elm": "^2.12.0", + "@parcel/transformer-image": "^2.12.0", + "@parcel/transformer-sass": "^2.12.0", + "bootstrap": "^5.3.3", "concurrently": "^8.2.2", + "elm": "^0.19.1-6", "elm-format": "^0.8.7", "elm-json": "^0.2.13", "elm-review": "^2.12.0", "elm-test": "0.19.1-revision12", + "git-cliff": "^2.6.0", + "highcharts": "^11.4.8", "jest": "^29.7.0", "nodemon": "^3.1.4", "npm-check-updates": "^17.1.0", + "parcel": "^2.12.0", "prettier": "^3.3.3", "process": "^0.11.10", "rimraf": "^6.0.1", - "supertest": "^7.0.0", - "parcel": "^2.12.0", - "@parcel/transformer-elm": "^2.12.0", - "@parcel/transformer-image": "^2.12.0", - "@parcel/transformer-sass": "^2.12.0", - "highcharts": "^11.4.8", - "bootstrap": "^5.3.3", - "elm": "^0.19.1-6" + "supertest": "^7.0.0" }, "cacheDirectories": [ "node_modules", From cc2d8540e9fab379f2b530a7b15bb99dbd2a250c Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 09:33:01 +0200 Subject: [PATCH 02/15] feat: create PR and release --- .github/workflows/changelog.yml | 98 ---------------- .github/workflows/create_pr_for_changelog.yml | 53 +++++++++ .github/workflows/create_release.yml | 106 ++++++++++++++++++ 3 files changed, 159 insertions(+), 98 deletions(-) delete mode 100644 .github/workflows/changelog.yml create mode 100644 .github/workflows/create_pr_for_changelog.yml create mode 100644 .github/workflows/create_release.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml deleted file mode 100644 index fb1860dab..000000000 --- a/.github/workflows/changelog.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: Generate changelog - -on: - push: - branches: [ master, staging ] - pull_request: - workflow_dispatch: - -permissions: - contents: write - pull-requests: write - -jobs: - changelog: - name: Generate changelog - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Generate the full changelog - uses: orhun/git-cliff-action@v4 - id: git-cliff - with: - config: cliff.toml - args: --verbose --exclude-path "data/" --bump - env: - OUTPUT: CHANGELOG-cliff.md - - - name: Generate latest changes - uses: orhun/git-cliff-action@v4 - id: git-cliff-latest - with: - config: cliff.toml - args: --verbose --exclude-path "data/" --bump --unreleased - - - name: Extract branch name - shell: bash - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT - id: extract_branch - - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v7 - with: - add-paths: | - CHANGELOG-cliff.md - base: master - commit-message: 'chore: update changelog for ${{ steps.git-cliff.outputs.version }}' - signoff: false - branch: chore/update-changelog-${{ steps.git-cliff.outputs.version }} - delete-branch: true - title: 'chore(release): release ${{ steps.git-cliff.outputs.version }}' - body: ${{ steps.git-cliff-latest.outputs.content }} - labels: | - pending-release - automated pr - - - # - name: Commit the changelog - # run: | - # git checkout ${{ steps.extract_branch.outputs.branch }} - # git config user.name 'github-actions[bot]' - # git config user.email 'github-actions[bot]@users.noreply.github.com' - # set +e - # git add CHANGELOG-cliff.md - # git commit -m "Update changelog" - # git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git ${{ steps.extract_branch.outputs.branch }} - # - # - name: Tag the next version - # run: | - # git checkout ${{ steps.extract_branch.outputs.branch }} - # git config user.name 'github-actions[bot]' - # git config user.email 'github-actions[bot]@users.noreply.github.com' - # set +e - # git tag -f ${{ steps.git-cliff.outputs.version }}-cliff-test - # git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git ${{ steps.git-cliff.outputs.version }}-cliff-test - # - # - name: Create dist archive - # uses: ./.github/actions/build-release - # id: create-dist-archive - # with: - # tag: ${{ steps.git-cliff.outputs.version }}-cliff-test - # commit_sha: ${{ github.event.pull_request.head.sha }} - # encryption_key: ${{ secrets.ENCRYPTION_KEY }} - # private_ssh_key: ${{ secrets.PRIVATE_SSH_KEY }} - # - # - # - name: Upload the release - # uses: svenstaro/upload-release-action@v2 - # with: - # file: ${{ steps.create-dist-archive.outputs.dist-archive}} - # repo_token: ${{ secrets.GITHUB_TOKEN }} - # tag: ${{ steps.git-cliff.outputs.version }}-cliff-test - # body: ${{ steps.git-cliff-latest.outputs.content }} - # draft: true diff --git a/.github/workflows/create_pr_for_changelog.yml b/.github/workflows/create_pr_for_changelog.yml new file mode 100644 index 000000000..981130e29 --- /dev/null +++ b/.github/workflows/create_pr_for_changelog.yml @@ -0,0 +1,53 @@ +name: Generate changelog PR + +on: + push: + branches: [master] + pull_request: + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + changelog: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Generate the full changelog + uses: orhun/git-cliff-action@v4 + id: git_cliff + with: + config: cliff.toml + args: --verbose --exclude-path "data/" --bump + env: + OUTPUT: CHANGELOG-cliff.md + + - name: Generate latest changes + uses: orhun/git-cliff-action@v4 + id: git_cliff_latest + with: + config: cliff.toml + args: --verbose --latest --strip header --exclude-path "data/" --bump --unreleased + + - name: Create Pull Request + if: steps.git_cliff.outputs.version != 'null' + uses: peter-evans/create-pull-request@v7 + with: + add-paths: | + CHANGELOG-cliff.md + base: main + commit-message: "chore: update CHANGELOG.md for ${{ steps.git_cliff.outputs.version }}" + signoff: false + branch: chore/next-release-changelog + delete-branch: true + title: "chore(release): release ${{ steps.git_cliff.outputs.version }}" + body: ${{ steps.git_cliff-latest.outputs.content }} + labels: | + pending-release + automated diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 000000000..869f184e7 --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,106 @@ +name: Create tag and release + +on: + pull_request: + types: [closed] + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +env: + ECOBALYSE_DATA_DIR: ./ecobalyse-private + +jobs: + create_tag_and_release: + # The tag and the release should be created only when the automated PR created by `create_pr_for_changelog` is merged + # Or to test it for now, by triggering a workflow dispatch by hand + if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'chore(release)') && contains(github.event.pull_request.labels.*.name, 'automated') && contains(github.event.pull_request.labels.*.name, 'pending-release')) + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get latest version + uses: orhun/git-cliff-action@v4 + id: git_cliff + with: + config: cliff.toml + args: -vv --latest --strip header --exclude-path "data/" --bump --unreleased + + - name: Set up Git + run: | + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Create and push tag + # If something went wrong when getting the latest version from `git-cliff` + # don't create a messy tag + if: steps.git_cliff.outputs.version != 'null' + id: tag_creation + run: | + git tag -a "${{ steps.git_cliff.outputs.version }}" -m "Release ${{ steps.git_cliff.outputs.version }}" + git push origin "${{ steps.git_cliff.outputs.version }}" + echo "tag_created=true" >> "$GITHUB_OUTPUT" + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + if: steps.tag_creation.outputs.tag_created + + - name: Install Node dependencies + if: steps.tag_creation.outputs.tag_created + run: npm ci --prefer-offline --no-audit + + - name: Clone the detailed impacts + if: steps.tag_creation.outputs.tag_created + run: | + eval `ssh-agent -s` + ssh-add - <<< '${{ secrets.PRIVATE_SSH_KEY }}' + git clone git@github.com:MTES-MCT/ecobalyse-private.git + + - name: Build app + if: steps.tag_creation.outputs.tag_created + env: + # Specify the created SHA to correctly update version.json + SOURCE_VERSION: ${{ steps.git_cliff.outputs.sha }} + TAG: ${{ steps.git_cliff.outputs.version }} + run: | + npm run build:standalone-app + + - name: Encrypt the impacts files + if: steps.tag_creation.outputs.tag_created + env: + ENCRYPTION_KEY: ${{ secrets.ENCRYPTION_KEY }} + run : | + # We include the encrypted detailed processes with the dist + # so that people with the encryption key could later on use the app with the exact + # files it was using on production + npm run encrypt $ECOBALYSE_DATA_DIR/data/textile/processes_impacts.json dist/processes_impacts_textile.json.enc + npm run encrypt $ECOBALYSE_DATA_DIR/data/food/processes_impacts.json dist/processes_impacts_food.json.enc + + - name: Generate dist archive + if: steps.tag_creation.outputs.tag_created + run: | + tar czvf ${{ steps.git_cliff.outputs.version }}-dist.tar.gz dist + + - name: Create release + if: steps.tag_creation.outputs.tag_created + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.git_cliff.outputs.version }} + body: ${{ steps.git_cliff.outputs.content }} + files: ${{ steps.git_cliff.outputs.version }}-dist.tar.gz + generate_release_notes: false + make_latest: true + # For testing purposes, always create a draft release for now + draft: true From 6a4dc6f9b4755101655772a16409b168d0c4f364 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 09:35:35 +0200 Subject: [PATCH 03/15] fix: base is master, not main --- .github/workflows/create_pr_for_changelog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_pr_for_changelog.yml b/.github/workflows/create_pr_for_changelog.yml index 981130e29..0bb6febe6 100644 --- a/.github/workflows/create_pr_for_changelog.yml +++ b/.github/workflows/create_pr_for_changelog.yml @@ -41,7 +41,7 @@ jobs: with: add-paths: | CHANGELOG-cliff.md - base: main + base: master commit-message: "chore: update CHANGELOG.md for ${{ steps.git_cliff.outputs.version }}" signoff: false branch: chore/next-release-changelog From 8f54e43a55ecfbbc3800700a65b32a3641409b10 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 09:43:57 +0200 Subject: [PATCH 04/15] fix: step name --- .github/workflows/create_pr_for_changelog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_pr_for_changelog.yml b/.github/workflows/create_pr_for_changelog.yml index 0bb6febe6..5c024f094 100644 --- a/.github/workflows/create_pr_for_changelog.yml +++ b/.github/workflows/create_pr_for_changelog.yml @@ -47,7 +47,7 @@ jobs: branch: chore/next-release-changelog delete-branch: true title: "chore(release): release ${{ steps.git_cliff.outputs.version }}" - body: ${{ steps.git_cliff-latest.outputs.content }} + body: ${{ steps.git_cliff_latest.outputs.content }} labels: | pending-release automated From fd8d34ad93e0f12a1fb75a352a7f4cd84a8656ff Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 09:44:39 +0200 Subject: [PATCH 05/15] fix: don't use useless remote and skip release commits --- cliff.toml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cliff.toml b/cliff.toml index 89335662c..85f7954b5 100644 --- a/cliff.toml +++ b/cliff.toml @@ -15,7 +15,7 @@ header = """ body = """ {% if version %}\ {% if previous.version %} - ## [{{ version | trim_start_matches(pat="v") }}](https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}/compare/{{ previous.version }}..{{ version }}) ({{ timestamp | date(format="%Y-%m-%d") }}) + ## [{{ version | trim_start_matches(pat="v") }}](https://github.com/MTES-MCT/ecobalyse/compare/{{ previous.version }}..{{ version }}) ({{ timestamp | date(format="%Y-%m-%d") }}) {% else %} ## {{ version | trim_start_matches(pat="v") }} ({{ timestamp | date(format="%Y-%m-%d") }}) @@ -71,7 +71,8 @@ commit_parsers = [ { message = "^refactor", group = "๐Ÿšœ Refactor" }, { message = "^style", group = "๐ŸŽจ Styling" }, { message = "^test", group = "๐Ÿงช Testing" }, - { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(release\\):", skip = true }, + { message = "^chore\\(master\\): release", skip = true }, { message = "^chore\\(deps.*\\)", skip = true }, { message = "^chore\\(pr\\)", skip = true }, { message = "^chore\\(pull\\)", skip = true }, @@ -85,7 +86,3 @@ filter_commits = false topo_order = false # sort the commits inside sections by oldest/newest order sort_commits = "oldest" - -[remote.github] -owner = "MTES-MCT" -repo = "ecobalyse" From 3a3e122c545ed2add204d925348b8de64572ecf7 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 09:48:31 +0200 Subject: [PATCH 06/15] fix: remove Snyk upgrades from changelog --- cliff.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/cliff.toml b/cliff.toml index 85f7954b5..5b61b71e2 100644 --- a/cliff.toml +++ b/cliff.toml @@ -76,6 +76,7 @@ commit_parsers = [ { message = "^chore\\(deps.*\\)", skip = true }, { message = "^chore\\(pr\\)", skip = true }, { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore\\(Snyk\\)", skip = true }, { message = "^chore|^ci", group = "โš™๏ธ Miscellaneous Tasks" }, { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, { message = "^revert", group = "โ—€๏ธ Revert" }, From d3d9253e33c4ed6e6cfeded9f90a634e8e775c17 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 15:50:12 +0200 Subject: [PATCH 07/15] chore: trigger tag and release creation for test purposes --- .github/workflows/create_release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 869f184e7..5d67b846f 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -2,6 +2,7 @@ name: Create tag and release on: pull_request: + # @FIX: add types back before merging types: [closed] workflow_dispatch: @@ -16,7 +17,8 @@ jobs: create_tag_and_release: # The tag and the release should be created only when the automated PR created by `create_pr_for_changelog` is merged # Or to test it for now, by triggering a workflow dispatch by hand - if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'chore(release)') && contains(github.event.pull_request.labels.*.name, 'automated') && contains(github.event.pull_request.labels.*.name, 'pending-release')) + # @FIX: remove the workflow dispatch and test PR detection "improve changelog by using" before merging + if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.title, 'improve changelog by using') || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'chore(release)') && contains(github.event.pull_request.labels.*.name, 'automated') && contains(github.event.pull_request.labels.*.name, 'pending-release')) runs-on: ubuntu-latest strategy: matrix: From d0f69bdeeb183430ad4a2ce5e750bd0fd4c89d82 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 15:51:00 +0200 Subject: [PATCH 08/15] fix: remove closed scope to test release generation --- .github/workflows/create_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 5d67b846f..cb8cb1ec0 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -3,7 +3,7 @@ name: Create tag and release on: pull_request: # @FIX: add types back before merging - types: [closed] + # types: [closed] workflow_dispatch: permissions: From bcbfb5ee38f14d728504fac94f599ce27ea4f759 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 16:00:41 +0200 Subject: [PATCH 09/15] chore: remove test conditions --- .github/workflows/create_pr_for_changelog.yml | 2 +- .github/workflows/create_release.yml | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create_pr_for_changelog.yml b/.github/workflows/create_pr_for_changelog.yml index 5c024f094..fbd9cebb2 100644 --- a/.github/workflows/create_pr_for_changelog.yml +++ b/.github/workflows/create_pr_for_changelog.yml @@ -26,7 +26,7 @@ jobs: config: cliff.toml args: --verbose --exclude-path "data/" --bump env: - OUTPUT: CHANGELOG-cliff.md + OUTPUT: CHANGELOG.md - name: Generate latest changes uses: orhun/git-cliff-action@v4 diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index cb8cb1ec0..dcc3b994c 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -2,9 +2,7 @@ name: Create tag and release on: pull_request: - # @FIX: add types back before merging - # types: [closed] - workflow_dispatch: + types: [closed] permissions: contents: write @@ -17,8 +15,7 @@ jobs: create_tag_and_release: # The tag and the release should be created only when the automated PR created by `create_pr_for_changelog` is merged # Or to test it for now, by triggering a workflow dispatch by hand - # @FIX: remove the workflow dispatch and test PR detection "improve changelog by using" before merging - if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.title, 'improve changelog by using') || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'chore(release)') && contains(github.event.pull_request.labels.*.name, 'automated') && contains(github.event.pull_request.labels.*.name, 'pending-release')) + if: (github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'chore(release)') && contains(github.event.pull_request.labels.*.name, 'automated') && contains(github.event.pull_request.labels.*.name, 'pending-release')) runs-on: ubuntu-latest strategy: matrix: From 76336df9539de61c5e7b5d773a29a2f2b840b5d6 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 16:51:41 +0200 Subject: [PATCH 10/15] fix: changelog file --- .github/workflows/create_pr_for_changelog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_pr_for_changelog.yml b/.github/workflows/create_pr_for_changelog.yml index fbd9cebb2..c57adbb3c 100644 --- a/.github/workflows/create_pr_for_changelog.yml +++ b/.github/workflows/create_pr_for_changelog.yml @@ -40,7 +40,7 @@ jobs: uses: peter-evans/create-pull-request@v7 with: add-paths: | - CHANGELOG-cliff.md + CHANGELOG.md base: master commit-message: "chore: update CHANGELOG.md for ${{ steps.git_cliff.outputs.version }}" signoff: false From 5f6f2793a6bf5e78301a9c4eb50f88bbf97ce797 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 17:07:19 +0200 Subject: [PATCH 11/15] chore: remove PR update on pull_request push --- .github/workflows/create_pr_for_changelog.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/create_pr_for_changelog.yml b/.github/workflows/create_pr_for_changelog.yml index c57adbb3c..706275cd2 100644 --- a/.github/workflows/create_pr_for_changelog.yml +++ b/.github/workflows/create_pr_for_changelog.yml @@ -3,7 +3,6 @@ name: Generate changelog PR on: push: branches: [master] - pull_request: workflow_dispatch: permissions: From 861d010a41df8ac87c11302536dc18f2798b01d4 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 17:13:31 +0200 Subject: [PATCH 12/15] fix: remove the draft flag for the release --- .github/workflows/create_release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index dcc3b994c..73b286b9f 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -101,5 +101,3 @@ jobs: files: ${{ steps.git_cliff.outputs.version }}-dist.tar.gz generate_release_notes: false make_latest: true - # For testing purposes, always create a draft release for now - draft: true From 23f3cf9faf224bfca2466f454f99433d362b22f6 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 17:16:15 +0200 Subject: [PATCH 13/15] fix: we don't need git-cliff locally --- package-lock.json | 236 ---------------------------------------------- package.json | 5 +- 2 files changed, 1 insertion(+), 240 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2747a475..edb78c619 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,6 @@ "elm-json": "^0.2.13", "elm-review": "^2.12.0", "elm-test": "0.19.1-revision12", - "git-cliff": "^2.6.0", "highcharts": "^11.4.8", "jest": "^29.7.0", "nodemon": "^3.1.4", @@ -7517,241 +7516,6 @@ "assert-plus": "^1.0.0" } }, - "node_modules/git-cliff": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/git-cliff/-/git-cliff-2.6.0.tgz", - "integrity": "sha512-ipMTSjMLjJN0z5AAWUvZJLBYISwu5NvmdrrXmsqwrJ1QXhOgsWOXobft86YH6JJVkKuyh/M4gdhNnAS0H4ldkw==", - "dev": true, - "dependencies": { - "execa": "^8.0.1" - }, - "bin": { - "git-cliff": "lib/cli/cli.js" - }, - "engines": { - "node": ">=18.19 || >=20.6 || >=21" - }, - "optionalDependencies": { - "git-cliff-darwin-arm64": "2.6.0", - "git-cliff-darwin-x64": "2.6.0", - "git-cliff-linux-arm64": "2.6.0", - "git-cliff-linux-x64": "2.6.0", - "git-cliff-windows-arm64": "2.6.0", - "git-cliff-windows-x64": "2.6.0" - } - }, - "node_modules/git-cliff-darwin-arm64": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/git-cliff-darwin-arm64/-/git-cliff-darwin-arm64-2.6.0.tgz", - "integrity": "sha512-WdBQmeLKDjJWl/Y6djgwqEUh8eYTJ5ljLea2M8qDhlEBMoC9Ew3VcRmdfTy2fSIxm7WBZm9T6ukkQj4vCv099Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/git-cliff-darwin-x64": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/git-cliff-darwin-x64/-/git-cliff-darwin-x64-2.6.0.tgz", - "integrity": "sha512-Zvio86pLAbFGI5khYtVloecKxOac9JV9gL8MR8Eb+1hsliH+LY6MGCzy7zsrDCWEJ9+nH5qfMB24UwABsZhbMg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/git-cliff-linux-arm64": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/git-cliff-linux-arm64/-/git-cliff-linux-arm64-2.6.0.tgz", - "integrity": "sha512-FdeulZysE/JFhHmCKnNqXUnOexC4Zg+AloD7DBaiTP5Af2dpVLbV0upjFj2GfQE/x0eGhZH5BqZM5uY6ANuMFQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/git-cliff-linux-x64": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/git-cliff-linux-x64/-/git-cliff-linux-x64-2.6.0.tgz", - "integrity": "sha512-lQDjcT1ieJZaC6ULvWcG/0s3+RgItnEsNSD37Xwh/p7HWaz7FZaWrkVySgWSsDahE0GdYnR8v5hs1C1plT2d6w==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/git-cliff-windows-arm64": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/git-cliff-windows-arm64/-/git-cliff-windows-arm64-2.6.0.tgz", - "integrity": "sha512-xREKhwIKJMZvUzU0nsu0pLt1LMMdWn3367OZoJTy1RyEzqAFpOZXdejuD0GSFCN/t9QgyDJWURQKFekyfKwYSg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/git-cliff-windows-x64": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/git-cliff-windows-x64/-/git-cliff-windows-x64-2.6.0.tgz", - "integrity": "sha512-wFnK2cizOrxpPZT4IHmSnUK0YQUuLuI4XZAJHepV4hU4GJWi6q1bIZGoQapRtfZ82bSEF+4EIstoDDoWVwmLGw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/git-cliff/node_modules/execa": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", - "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^8.0.1", - "human-signals": "^5.0.0", - "is-stream": "^3.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^5.1.0", - "onetime": "^6.0.0", - "signal-exit": "^4.1.0", - "strip-final-newline": "^3.0.0" - }, - "engines": { - "node": ">=16.17" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/git-cliff/node_modules/get-stream": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", - "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", - "dev": true, - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/git-cliff/node_modules/human-signals": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", - "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", - "dev": true, - "engines": { - "node": ">=16.17.0" - } - }, - "node_modules/git-cliff/node_modules/is-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", - "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", - "dev": true, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/git-cliff/node_modules/mimic-fn": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", - "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/git-cliff/node_modules/npm-run-path": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", - "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", - "dev": true, - "dependencies": { - "path-key": "^4.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/git-cliff/node_modules/onetime": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", - "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", - "dev": true, - "dependencies": { - "mimic-fn": "^4.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/git-cliff/node_modules/path-key": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", - "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/git-cliff/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/git-cliff/node_modules/strip-final-newline": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", - "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/glob": { "version": "10.4.5", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", diff --git a/package.json b/package.json index d89b5ecc4..d6847c2a1 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,6 @@ "build": "npm run server:build && rimraf dist && npm run build:init && parcel build index.html --public-url ./", "build:init": "./bin/update-version.sh && mkdir -p dist && cp -r public/* dist/ && npm run db:build", "build:standalone-app": "npm run build && npm run server:build && cp server-app.js dist/ && cp openapi.yaml dist/", - "changelog:generate": "git-cliff -o CHANGELOG-cliff.md --exclude-path 'data/'", - "changelog:generate:bump": "npm run changelog:generate -- --bump", "decrypt": "./bin/decrypt", "encrypt": "./bin/encrypt", "db:build": "./bin/build-db && npm run db:check", @@ -55,8 +53,8 @@ "dependencies": { "@sentry/browser": "^8.28.0", "@sentry/node": "^8.29.0", - "@sentry/tracing": "^7.119.0", "@sentry/profiling-node": "^8.29.0", + "@sentry/tracing": "^7.119.0", "cors": "^2.8.5", "dotenv": "^16.4.5", "express": "^4.21.0", @@ -77,7 +75,6 @@ "elm-json": "^0.2.13", "elm-review": "^2.12.0", "elm-test": "0.19.1-revision12", - "git-cliff": "^2.6.0", "highcharts": "^11.4.8", "jest": "^29.7.0", "nodemon": "^3.1.4", From f1599ab87b040069ab7bc4539143407b758ca690 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Wed, 9 Oct 2024 17:17:48 +0200 Subject: [PATCH 14/15] fix: remove useless actions --- .github/actions/build-release/action.yml | 76 --------------------- .github/workflows/release-please.yml | 84 ------------------------ 2 files changed, 160 deletions(-) delete mode 100644 .github/actions/build-release/action.yml delete mode 100644 .github/workflows/release-please.yml diff --git a/.github/actions/build-release/action.yml b/.github/actions/build-release/action.yml deleted file mode 100644 index d65b3b1a9..000000000 --- a/.github/actions/build-release/action.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: "Build a release" -description: "Create the dist files for a specific version" - -inputs: - tag: - description: 'The tag we want to create the release for' - required: true - # @FIX: this should not be required? - commit_sha: - description: 'The commit of the tag' - required: true - encryption_key: - description: 'The key used to encypt the detailed processes' - required: true - private_ssh_key: - description: 'The private ssh key used to clone the detailed impacts' - required: true - ecobalyse_data_dir: - description: 'The path to the ecobalyse dir containing the detailed impacts' - required: false - default: "./ecobalyse-private" -outputs: - dist-archive: - description: "Dist archive file path" - value: ${{ steps.create-dist-archive.outputs.dist-archive }} - - -runs: - using: "composite" - steps: - - - uses: actions/setup-node@v4 - with: - node-version: "20.x" - cache: 'npm' - - - name: Install Node dependencies - shell: bash - run: npm ci --prefer-offline --no-audit - - - name: Clone the detailed impacts - shell: bash - run: | - eval `ssh-agent -s` - ssh-add - <<< '${{ inputs.private_ssh_key }}' - git clone git@github.com:MTES-MCT/ecobalyse-private.git - - - name: Build app - shell: bash - env: - # Specify the created SHA to correctly update version.json - # @FIX: this should not be requiered when creating a tagged version - SOURCE_VERSION: ${{ inputs.commit_sha }} - TAG: ${{ inputs.tag }} - ECOBALYSE_DATA_DIR: ${{ inputs.ecobalyse_data_dir }} - run: | - npm run build:standalone-app - - - name: Encrypt the impacts files - shell: bash - env: - ENCRYPTION_KEY: ${{ inputs.encryption_key }} - ECOBALYSE_DATA_DIR: ${{ inputs.ecobalyse_data_dir }} - run : | - # We include the encrypted detailed processes with the dist - # so that people with the encryption key could later on use the app with the exact - # files it was using on production - npm run encrypt $ECOBALYSE_DATA_DIR/data/textile/processes_impacts.json dist/processes_impacts_textile.json.enc - npm run encrypt $ECOBALYSE_DATA_DIR/data/food/processes_impacts.json dist/processes_impacts_food.json.enc - - - name: Generate dist archive - shell: bash - id: create-dist-archive - run: | - tar czvf ${{ inputs.tag }}-dist.tar.gz dist - echo "dist-archive=${{ inputs.tag }}-dist.tar.gz" >> $GITHUB_OUTPUT diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml deleted file mode 100644 index 7c2c96024..000000000 --- a/.github/workflows/release-please.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: release-please - -on: - push: - branches: - - master - -permissions: - contents: write - pull-requests: write - -env: - ECOBALYSE_DATA_DIR: ./ecobalyse-private - -jobs: - release-please: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x] - steps: - - uses: googleapis/release-please-action@v4 - id: release - with: - token: ${{ secrets.GITHUB_TOKEN }} - release-type: node - - # The logic below handles the static assets publication - - uses: actions/checkout@v4 - if: ${{ steps.release.outputs.release_created }} - - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - if: ${{ steps.release.outputs.release_created }} - - - name: Install Node dependencies - if: ${{ steps.release.outputs.release_created }} - run: npm ci --prefer-offline --no-audit - - - name: Clone the detailed impacts - if: ${{ steps.release.outputs.release_created }} - run: | - eval `ssh-agent -s` - ssh-add - <<< '${{ secrets.PRIVATE_SSH_KEY }}' - git clone git@github.com:MTES-MCT/ecobalyse-private.git - - - name: Build app - if: ${{ steps.release.outputs.release_created }} - env: - # Specify the created SHA to correctly update version.json - SOURCE_VERSION: ${{ steps.release.outputs.sha }} - TAG: ${{ steps.release.outputs.tag_name }} - run: | - npm run build:standalone-app - - - name: Encrypt the impacts files - if: ${{ steps.release.outputs.release_created }} - env: - ENCRYPTION_KEY: ${{ secrets.ENCRYPTION_KEY }} - run : | - # We include the encrypted detailed processes with the dist - # so that people with the encryption key could later on use the app with the exact - # files it was using on production - npm run encrypt $ECOBALYSE_DATA_DIR/data/textile/processes_impacts.json dist/processes_impacts_textile.json.enc - npm run encrypt $ECOBALYSE_DATA_DIR/data/food/processes_impacts.json dist/processes_impacts_food.json.enc - - - name: Generate dist archive - if: ${{ steps.release.outputs.release_created }} - run: | - tar czvf ${{ steps.release.outputs.tag_name }}-dist.tar.gz dist - - - name: Archive production artifacts - uses: actions/upload-artifact@v4 - with: - name: dist - path: dist - if: ${{ steps.release.outputs.release_created }} - - - name: Upload Release Artifact - if: ${{ steps.release.outputs.release_created }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release upload ${{ steps.release.outputs.tag_name }} ${{ steps.release.outputs.tag_name }}-dist.tar.gz From ad0514120d8ec666633042dea98be37faa74d747 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Thu, 10 Oct 2024 11:30:25 +0200 Subject: [PATCH 15/15] fix: @n1k0 review --- .github/workflows/create_pr_for_changelog.yml | 3 ++- cliff.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create_pr_for_changelog.yml b/.github/workflows/create_pr_for_changelog.yml index 706275cd2..645d9a918 100644 --- a/.github/workflows/create_pr_for_changelog.yml +++ b/.github/workflows/create_pr_for_changelog.yml @@ -42,7 +42,8 @@ jobs: CHANGELOG.md base: master commit-message: "chore: update CHANGELOG.md for ${{ steps.git_cliff.outputs.version }}" - signoff: false + signoff: true + sign-commits: true branch: chore/next-release-changelog delete-branch: true title: "chore(release): release ${{ steps.git_cliff.outputs.version }}" diff --git a/cliff.toml b/cliff.toml index 5b61b71e2..7b544e2ea 100644 --- a/cliff.toml +++ b/cliff.toml @@ -65,7 +65,7 @@ commit_preprocessors = [ # regex for parsing and grouping commits commit_parsers = [ { message = "^feat", group = "๐Ÿš€ Features" }, - { message = "^fix", group = "๐Ÿ› Bug Fixes" }, + { message = "^fix", group = "๐Ÿชฒ Bug Fixes" }, { message = "^doc", group = "๐Ÿ“š Documentation" }, { message = "^perf", group = "โšก Performance" }, { message = "^refactor", group = "๐Ÿšœ Refactor" },