From 4fc2e9175830d16186f3080b32d7ff2fcfbf2b02 Mon Sep 17 00:00:00 2001 From: Dereck Mezquita Date: Mon, 2 Sep 2024 19:55:56 -0500 Subject: [PATCH] STAT-12: Update workflow to use timestamp for dev release. --- .github/workflows/npm_publish_dev.yml | 31 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/npm_publish_dev.yml b/.github/workflows/npm_publish_dev.yml index f177379..e6cf7c5 100644 --- a/.github/workflows/npm_publish_dev.yml +++ b/.github/workflows/npm_publish_dev.yml @@ -4,6 +4,7 @@ on: push: branches-ignore: - 'master' + jobs: build-and-publish-dev: runs-on: ubuntu-latest @@ -13,12 +14,28 @@ jobs: with: node-version: 20 registry-url: https://registry.npmjs.org/ - - run: yarn install --frozen-lockfile - - run: yarn test - - run: | - while true; do - npm version prerelease --preid=dev --no-git-tag-version - npm publish --tag dev && break - done + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run tests + run: yarn test + + - name: Get current version + id: package-version + uses: martinbeentjes/npm-get-version-action@v1.3.1 + + - name: Generate unique version + id: generate-version + run: | + current_version=$(echo ${{ steps.package-version.outputs.current-version}} | sed 's/-dev\.[0-9]\+$//') + timestamp=$(date +%Y%m%d%H%M%S) + echo "new_version=${current_version}-dev.${timestamp}" >> $GITHUB_OUTPUT + + - name: Update version + run: npm version ${{ steps.generate-version.outputs.new_version }} --no-git-tag-version + + - name: Publish to npm + run: npm publish --tag dev env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}