Calculate tag for releases based on package.json version (#9572)

* calculate tag for the release

This is based on the name we use in the version e.g.: `3.2.0-beta.2`. If
no name can be found in the version, we will default to `latest`

* ignore node_modules caching for now
This commit is contained in:
Robin Malfait 2022-10-16 16:20:21 +02:00 committed by GitHub
parent 855fa300a0
commit c2854dae71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 28 deletions

View File

@ -33,19 +33,19 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Use cached node_modules (tailwindcss)
id: cache-tailwindcss
uses: actions/cache@v3
with:
path: node_modules
key: nodeModules-${{ hashFiles('./package-lock.json') }}-${{ matrix.node-version }}-tailwindcss
restore-keys: |
nodeModules-
# cache: 'npm'
#
# - name: Use cached node_modules (tailwindcss)
# id: cache-tailwindcss
# uses: actions/cache@v3
# with:
# path: node_modules
# key: nodeModules-${{ hashFiles('./package-lock.json') }}-${{ matrix.node-version }}-tailwindcss
# restore-keys: |
# nodeModules-
- name: Install dependencies
if: steps.cache-tailwindcss.outputs.cache-hit != 'true'
# if: steps.cache-tailwindcss.outputs.cache-hit != 'true'
run: npm install
env:
CI: true

View File

@ -26,8 +26,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# cache: 'npm'
# cache: 'npm'
#
# - name: Use cached node_modules
# id: cache
# uses: actions/cache@v3

View File

@ -23,8 +23,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
# cache: 'npm'
# cache: 'npm'
#
# - name: Use cached node_modules
# id: cache
# uses: actions/cache@v3

View File

@ -23,19 +23,19 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Use cached node_modules
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: nodeModules-${{ hashFiles('**/package-lock.json') }}-${{ matrix.node-version }}
restore-keys: |
nodeModules-
# cache: 'npm'
#
# - name: Use cached node_modules
# id: cache
# uses: actions/cache@v3
# with:
# path: node_modules
# key: nodeModules-${{ hashFiles('**/package-lock.json') }}-${{ matrix.node-version }}
# restore-keys: |
# nodeModules-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
# if: steps.cache.outputs.cache-hit != 'true'
run: npm install
env:
CI: true
@ -45,8 +45,12 @@ jobs:
env:
CI: true
- name: Calculate tag
run: |
echo "tag_name=$(npm run calculate-tag-name --silent)" >> $GITHUB_ENV
- name: Publish
run: npm publish
run: npm publish --tag ${{ env.tag_name }}
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@ -26,7 +26,8 @@
"posttest": "npm run style",
"generate:plugin-list": "node -r @swc/register scripts/create-plugin-list.js",
"generate:types": "node -r @swc/register scripts/generate-types.js",
"generate": "npm run generate:plugin-list && npm run generate:types"
"generate": "npm run generate:plugin-list && npm run generate:types",
"calculate-tag-name": "node scripts/calculate-tag-name.js"
},
"files": [
"src/*",

View File

@ -0,0 +1,8 @@
let version = process.env.npm_package_version || require('../package.json').version
let match = /\d+\.\d+\.\d+-(.*)\.\d+/g.exec(version)
if (match) {
console.log(match[1])
} else {
console.log('latest')
}