diff --git a/.github/workflows/repo.yml b/.github/workflows/repo.yml index f6ca5ff4..a5c0ed37 100644 --- a/.github/workflows/repo.yml +++ b/.github/workflows/repo.yml @@ -56,6 +56,14 @@ jobs: with: cmd: build + - name: Cache build directory + uses: actions/cache@v3 + with: + path: . + key: ${{ runner.os }}-build-${{ hashFiles('build.tgz') }} + restore-keys: | + ${{ runner.os }}-build- + test: needs: setup runs-on: ubuntu-latest @@ -100,28 +108,44 @@ jobs: cache: 'npm' registry-url: 'https://registry.npmjs.org/' - - name: Restore node modules from cache + # Restore Build cache + - name: Restore build cache uses: actions/cache@v3 with: - path: node_modules - key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + path: . + key: ${{ runner.os }}-build-${{ hashFiles('build.tgz') }} restore-keys: | - ${{ runner.os }}-node- + ${{ runner.os }}-build- + + - name: Show workspace contents + run: | + ls -R . - name: Prepare version for publish id: prep run: | + # Extract the pull request number and the short SHA of the commit PR_NUMBER=$(echo ${{ github.event.number }}) COMMIT_SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7) + + # Extract the current version from package.json CURRENT_VERSION=$(node -p "require('./package.json').version") - NEW_VERSION="${CURRENT_VERSION}-dev.${PR_NUMBER}.${COMMIT_SHORT_SHA}" + + # If the current version includes '-rc.', remove it and everything after + # This step ensures that we start with a base version like '3.0.0' even if it was a release candidate + BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-rc.*//') + + # Construct the new version string + NEW_VERSION="${BASE_VERSION}-dev.${PR_NUMBER}.${COMMIT_SHORT_SHA}" + + # Output the new version for use in subsequent GitHub Actions steps echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV - name: Echo version for testing run: | echo "Version to publish: $NEW_VERSION" - - name: Publish to npm - run: | - npm version $NEW_VERSION - npm publish --tag dev \ No newline at end of file + # - name: Publish to npm + # run: | + # npm version $NEW_VERSION + # npm publish --tag dev \ No newline at end of file