From 63d644d95fc06cffb5d8073d3de7567e6f0fd545 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sat, 20 Mar 2021 00:09:12 +0100 Subject: [PATCH] Update deps and CI workflow --- .github/workflows/ci.yaml | 164 +++++++++++++++++++++------------ .github/workflows/publish.yaml | 116 ----------------------- package.json | 4 +- yarn.lock | 28 +++--- 4 files changed, 122 insertions(+), 190 deletions(-) delete mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e119a320..56f0a3c3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,14 +2,14 @@ name: ci on: push: branches: - - develop + - main pull_request: branches: - - develop + - main jobs: - test_node: + test: runs-on: macos-10.15 strategy: matrix: @@ -17,72 +17,120 @@ jobs: name: Test with Node v${{ matrix.node }} steps: - name: Tell if project is using npm or yarn - id: _1 - uses: garronej/github_actions_toolkit@v1.11 + id: step1 + uses: garronej/github_actions_toolkit@v2.2 with: action_name: tell_if_project_uses_npm_or_yarn - owner: ${{github.repository_owner}} - repo: ${{github.event.repository.name}} - branch: ${{github.ref}} - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-node@v2.1.3 with: node-version: ${{ matrix.node }} - - if: steps._1.outputs.npm_or_yarn == 'yarn' + - if: steps.step1.outputs.npm_or_yarn == 'yarn' run: | yarn install --frozen-lockfile - yarn run build - yarn run test - - if: steps._1.outputs.npm_or_yarn == 'npm' + yarn build + yarn test + - if: steps.step1.outputs.npm_or_yarn == 'npm' run: | npm ci npm run build - npm run test - trigger_publish: - name: Trigger publish.yaml workflow if package.json version updated ( and secrets.PAT is set ). + npm test + check_if_version_upgraded: + name: Check if version upgrade + if: github.event_name == 'push' runs-on: ubuntu-latest - env: - PAT: ${{secrets.PAT}} - if: github.event_name == 'push' && github.event.head_commit.author.name != 'ts_ci' - needs: test_node + needs: test + outputs: + from_version: ${{ steps.step1.outputs.from_version }} + to_version: ${{ steps.step1.outputs.to_version }} + is_upgraded_version: ${{steps.step1.outputs.is_upgraded_version }} steps: - - - name: Get version on latest - id: v_latest - uses: garronej/github_actions_toolkit@v1.11 + - uses: garronej/github_actions_toolkit@v2.2 + id: step1 with: - action_name: get_package_json_version - owner: ${{github.repository_owner}} - repo: ${{github.event.repository.name}} - branch: latest - compare_to_version: '0.0.0' + action_name: is_package_json_version_upgraded - - name: Get version on develop - id: v_develop - uses: garronej/github_actions_toolkit@v1.11 - with: - action_name: get_package_json_version - owner: ${{github.repository_owner}} - repo: ${{github.event.repository.name}} - branch: ${{ github.sha }} - compare_to_version: ${{steps.v_latest.outputs.version || '0.0.0'}} - - - name: 'Trigger the ''publish'' workflow' - if: ${{ !!env.PAT && steps.v_develop.outputs.compare_result == '1' }} - uses: garronej/github_actions_toolkit@v1.11 - env: - GITHUB_TOKEN: ${{ secrets.PAT }} + update_changelog: + runs-on: ubuntu-latest + needs: check_if_version_upgraded + if: needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' + steps: + - uses: garronej/github_actions_toolkit@v2.2 with: - action_name: dispatch_event - owner: ${{github.repository_owner}} - repo: ${{github.event.repository.name}} - event_type: publish - client_payload_json: | - ${{ - format( - '{{"from_version":"{0}","to_version":"{1}","repo":"{2}"}}', - steps.v_latest.outputs.version, - steps.v_develop.outputs.version, - github.event.repository.name - ) - }} + action_name: update_changelog + branch: ${{ github.ref }} + commit_author_email: ts_ci@github.com + + create_github_release: + runs-on: ubuntu-latest + needs: + - update_changelog + - check_if_version_upgraded + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + - name: Build GitHub release body + id: step1 + run: | + if [ "$FROM_VERSION" = "0.0.0" ]; then + echo "::set-output name=body::🚀" + else + echo "::set-output name=body::📋 [CHANGELOG](https://github.com/$GITHUB_REPOSITORY/blob/v$TO_VERSION/CHANGELOG.md)" + fi + env: + FROM_VERSION: ${{ needs.check_if_version_upgraded.outputs.from_version }} + TO_VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }} + - uses: garronej/action-gh-release@v0.2.0 + with: + name: Release v${{ needs.check_if_version_upgraded.outputs.to_version }} + tag_name: v${{ needs.check_if_version_upgraded.outputs.to_version }} + target_commitish: ${{ github.ref }} + body: ${{ steps.step1.outputs.body }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish_on_npm: + runs-on: macos-10.15 + needs: + - update_changelog + - check_if_version_upgraded + steps: + - uses: actions/checkout@v2.3.4 + with: + ref: ${{ github.ref }} + - uses: actions/setup-node@v2.1.3 + with: + node-version: '15' + - run: | + PACKAGE_MANAGER=npm + if [ -f "./yarn.lock" ]; then + PACKAGE_MANAGER=yarn + fi + if [ "$PACKAGE_MANAGER" = "yarn" ]; then + yarn install --frozen-lockfile + else + npm ci + fi + $PACKAGE_MANAGER run build + - run: npx -y -p denoify@0.6.5 denoify_enable_short_npm_import_path + env: + DRY_RUN: "0" + - name: Publishing on NPM + run: | + if [ "$(npm show . version)" = "$VERSION" ]; then + echo "This version is already published" + exit 0 + fi + if [ "$NPM_TOKEN" = "" ]; then + echo "Can't publish on NPM, You must first create a secret called NPM_TOKEN that contains your NPM auth token. https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets" + false + fi + echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc + npm publish + rm .npmrc + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }} \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 23771027..00000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,116 +0,0 @@ -on: - repository_dispatch: - types: publish - -jobs: - update_changelog_and_sync_package_lock_version: - name: Update CHANGELOG.md and make sure package.json and package-lock.json versions matches. - runs-on: ubuntu-latest - steps: - - name: Synchronize package.json and package-lock.json version if needed. - uses: garronej/github_actions_toolkit@v1.11 - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - with: - action_name: sync_package_and_package_lock_version - owner: ${{github.repository_owner}} - repo: ${{github.event.client_payload.repo}} - branch: develop - commit_author_email: ts_ci@github.com - - name: Update CHANGELOG.md - if: ${{ !!github.event.client_payload.from_version }} - uses: garronej/github_actions_toolkit@v1.11 - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - with: - action_name: update_changelog - owner: ${{github.repository_owner}} - repo: ${{github.event.client_payload.repo}} - branch_behind: latest - branch_ahead: develop - commit_author_email: ts_ci@github.com - exclude_commit_from_author_names_json: '["ts_ci"]' - - publish: - runs-on: macos-10.15 - needs: update_changelog_and_sync_package_lock_version - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ref: develop - - name: Remove .github directory, useless on 'latest' branch - run: rm -r .github - - name: Remove branch 'latest' - continue-on-error: true - run: | - git branch -d latest || true - git push origin :latest - - name: Create the new 'latest' branch - run: | - git branch latest - git checkout latest - - uses: actions/setup-node@v1 - - run: | - if [ -f "./yarn.lock" ]; then - yarn install --frozen-lockfile - else - npm ci - fi - - run: | - PACKAGE_MANAGER=npm - if [ -f "./yarn.lock" ]; then - PACKAGE_MANAGER=yarn - fi - $PACKAGE_MANAGER run enable_short_import_path - env: - DRY_RUN: "0" - - name: (DEBUG) Show how the files have been moved to enable short import - run: ls -lR - - name: Publishing on NPM - run: | - if [ "$(npm show . version)" = "$VERSION" ]; then - echo "This version is already published" - exit 0 - fi - if [ "$NPM_TOKEN" = "" ]; then - echo "Can't publish on NPM, You must first create a secret called NPM_TOKEN that contains your NPM auth token. https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets" - false - fi - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc - npm publish - rm .npmrc - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - VERSION: ${{ github.event.client_payload.to_version }} - - name: Commit changes - run: | - git config --local user.email "ts_ci@github.com" - git config --local user.name "ts_ci" - git add -A - git commit -am "Enabling shorter import paths [automatic]" - - run: git push origin latest - - name: Release body - id: id_rb - run: | - if [ "$FROM_VERSION" = "" ]; then - echo "::set-output name=body::🚀" - else - echo "::set-output name=body::📋 [CHANGELOG](https://github.com/$OWNER/$REPO/blob/$REF/CHANGELOG.md)" - fi - env: - FROM_VERSION: ${{ github.event.client_payload.from_version }} - OWNER: ${{github.repository_owner}} - REPO: ${{github.event.client_payload.repo}} - REF: v${{github.event.client_payload.to_version}} - - name: Create Release - uses: garronej/create-release@master - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - with: - tag_name: v${{ github.event.client_payload.to_version }} - release_name: Release v${{ github.event.client_payload.to_version }} - branch: latest - draft: false - prerelease: false - body: ${{ steps.id_rb.outputs.body }} diff --git a/package.json b/package.json index c99397d7..860585f0 100755 --- a/package.json +++ b/package.json @@ -49,14 +49,14 @@ "properties-parser": "^0.3.1", "react": "^17.0.1", "rimraf": "^3.0.2", - "typescript": "^4.1.5" + "typescript": "^4.2.3" }, "dependencies": { "cheerio": "^1.0.0-rc.5", "evt": "2.0.0-beta.15", "minimal-polyfills": "^2.1.6", "path": "^0.12.7", - "powerhooks": "^0.0.21", + "powerhooks": "^0.0.27", "scripting-tools": "^0.19.13", "tss-react": "^0.0.11" } diff --git a/yarn.lock b/yarn.lock index 2f0cf359..e30535a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -147,9 +147,9 @@ "@octokit/types" "^6.0.3" "@octokit/core@^3.2.3": - version "3.3.0" - resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.3.0.tgz#58afc26c302e22cf97491bad9a30b2f33e2bcaed" - integrity sha512-GGMpjaodCBY7JrtOwfolMocwZw9Pj5NxuQqfaJhGau4tkyonm0JRV9D6juQYLMb1Kl261++4Q980o0FlAtg8jg== + version "3.3.1" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.3.1.tgz#c6bb6ba171ad84a5f430853a98892cfe8f93d8cd" + integrity sha512-Dc5NNQOYjgZU5S1goN6A/E500yXOfDUFRGQB8/2Tl16AcfvS3H9PudyOe3ZNE/MaVyHPIfC0htReHMJb1tMrvw== dependencies: "@octokit/auth-token" "^2.4.4" "@octokit/graphql" "^4.5.8" @@ -183,9 +183,9 @@ integrity sha512-NxF1yfYOUO92rCx3dwvA2onF30Vdlg7YUkMVXkeptqpzA3tRLplThhFleV/UKWFgh7rpKu1yYRbvNDUtzSopKA== "@octokit/plugin-paginate-rest@^2.6.2": - version "2.13.2" - resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.13.2.tgz#7b8244a0dd7a31135ba2adc58a533213837bfe87" - integrity sha512-mjfBcla00UNS4EI/NN7toEbUM45ow3kk4go+LxsXAFLQodsrXcIZbftUhXTqi6ZKd+r6bcqMI+Lv4dshLtFjww== + version "2.13.3" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.13.3.tgz#f0f1792230805108762d87906fb02d573b9e070a" + integrity sha512-46lptzM9lTeSmIBt/sVP/FLSTPGx6DCzAdSX3PfeJ3mTf4h9sGC26WpaQzMEq/Z44cOcmx8VsOhO+uEgE3cjYg== dependencies: "@octokit/types" "^6.11.0" @@ -944,10 +944,10 @@ path@^0.12.7: process "^0.11.1" util "^0.10.3" -powerhooks@^0.0.21: - version "0.0.21" - resolved "https://registry.yarnpkg.com/powerhooks/-/powerhooks-0.0.21.tgz#0eebaffa3193157981f8cdadd38e76c59e98bb82" - integrity sha512-CmysMra4VNK0eU70PtvxVBzGIi5SXS+oFI2Hd1R5VPzCbQh0ud56EBvfZT5jmnrKAzoLOW6W01FGRwgFskEJfg== +powerhooks@^0.0.27: + version "0.0.27" + resolved "https://registry.yarnpkg.com/powerhooks/-/powerhooks-0.0.27.tgz#e9dc29258860d2f6bf32b249d9cba07c6f53f393" + integrity sha512-ohayWhtIEdLqiC2th/GEhaRfOhqekFg2uFo0JZ8Dn7oTnAZybs618QJeq5ag9oy3lFVzl+kbROpVa8Ch5zrkaA== dependencies: evt "2.0.0-beta.15" memoizee "^0.4.15" @@ -1146,7 +1146,7 @@ type@^2.0.0: resolved "https://registry.yarnpkg.com/type/-/type-2.5.0.tgz#0a2e78c2e77907b252abe5f298c1b01c63f0db3d" integrity sha512-180WMDQaIMm3+7hGXWf12GtdniDEy7nYcyFMKJn/eZz/6tSLXrUN9V0wKSbMjej0I1WHWbpREDEKHtqPQa9NNw== -typescript@^4.1.5: +typescript@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3" integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw== @@ -1203,9 +1203,9 @@ y18n@^5.0.5: integrity sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg== yaml@^1.7.2: - version "1.10.1" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.1.tgz#bb13d805ed104fba38f533570f3441027eeeca22" - integrity sha512-z/asvd+V08l1ywhaemZVirCwjdzLo6O1/0j2JbYCsGjiezupNQqjs5IIPyNtctbHjPEckqzVGd4jvpU5Lr25vQ== + version "1.10.2" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" + integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== yargs-parser@^20.2.2: version "20.2.7"