From 7e7edd62583d1b5bbc92b32c37cdf86611566cc0 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Fri, 26 Feb 2021 21:32:19 +0100 Subject: [PATCH] Yarn support --- .github/workflows/ci.yaml | 29 ++++++++++++++----- .github/workflows/publish.yaml | 20 +++++++++---- .../workflows/template_initialization.yaml | 4 +-- README.md | 2 ++ 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9ff9115..ced62fb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,15 +30,28 @@ jobs: os: [ windows-latest, ubuntu-latest ] name: Test with Node v${{ matrix.node }} on ${{ matrix.os }} steps: + - name: Tell if project is using npm or yarn + id: _1 + uses: garronej/github_actions_toolkit@v1.11 + 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 with: node-version: ${{ matrix.node }} - - run: npm ci - - run: npm run build - - run: npm run test - - + - if: steps._1.npm_or_yarn == 'yarn' + run: | + yarn install --frozen-lockfile + yarn run build + yarn run test + - if: steps._1.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 ). runs-on: ubuntu-latest @@ -50,7 +63,7 @@ jobs: - name: Get version on latest id: v_latest - uses: garronej/github_actions_toolkit@v1.9 + uses: garronej/github_actions_toolkit@v1.11 with: action_name: get_package_json_version owner: ${{github.repository_owner}} @@ -60,7 +73,7 @@ jobs: - name: Get version on develop id: v_develop - uses: garronej/github_actions_toolkit@v1.9 + uses: garronej/github_actions_toolkit@v1.11 with: action_name: get_package_json_version owner: ${{github.repository_owner}} @@ -70,7 +83,7 @@ jobs: - name: 'Trigger the ''publish'' workflow' if: ${{ !!env.PAT && steps.v_develop.outputs.compare_result == '1' }} - uses: garronej/github_actions_toolkit@v1.9 + uses: garronej/github_actions_toolkit@v1.11 env: GITHUB_TOKEN: ${{ secrets.PAT }} with: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 43c6fbf..f973285 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Synchronize package.json and package-lock.json version if needed. - uses: garronej/github_actions_toolkit@v1.9 + uses: garronej/github_actions_toolkit@v1.11 env: GITHUB_TOKEN: ${{ secrets.PAT }} with: @@ -19,7 +19,7 @@ jobs: commit_author_email: ts_ci@github.com - name: Update CHANGELOG.md if: ${{ !!github.event.client_payload.from_version }} - uses: garronej/github_actions_toolkit@v1.9 + uses: garronej/github_actions_toolkit@v1.11 env: GITHUB_TOKEN: ${{ secrets.PAT }} with: @@ -51,8 +51,18 @@ jobs: git branch latest git checkout latest - uses: actions/setup-node@v1 - - run: npm ci - - run: npm run enable_short_import_path + - 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 @@ -103,4 +113,4 @@ jobs: branch: latest draft: false prerelease: false - body: ${{ steps.id_rb.outputs.body }} + body: ${{ steps.id_rb.outputs.body }} \ No newline at end of file diff --git a/.github/workflows/template_initialization.yaml b/.github/workflows/template_initialization.yaml index 4c124dc..c4a2835 100644 --- a/.github/workflows/template_initialization.yaml +++ b/.github/workflows/template_initialization.yaml @@ -1,8 +1,6 @@ name: template_initialization on: - create: - branches: - - develop + create jobs: template_initialization: diff --git a/README.md b/README.md index f34ac23..f3fa221 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ --- +NEW: `yarn` support ✅ You are now free to use yarn instead of `npm` if you'd like to. + ⚠WARNING⚠: There is currently a problem with the initialization workflow that does not trigger automatically. I am trying to adress the problem but for now the workaround is to manually edit `.github/workflow/template_initialization.yaml` and replace: