Skip to content

Commit c2854da

Browse files
authored
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
1 parent 855fa30 commit c2854da

File tree

6 files changed

+41
-28
lines changed

6 files changed

+41
-28
lines changed

.github/workflows/integration-tests.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ jobs:
3333
uses: actions/setup-node@v3
3434
with:
3535
node-version: ${{ matrix.node-version }}
36-
cache: 'npm'
37-
38-
- name: Use cached node_modules (tailwindcss)
39-
id: cache-tailwindcss
40-
uses: actions/cache@v3
41-
with:
42-
path: node_modules
43-
key: nodeModules-${{ hashFiles('./package-lock.json') }}-${{ matrix.node-version }}-tailwindcss
44-
restore-keys: |
45-
nodeModules-
36+
# cache: 'npm'
37+
#
38+
# - name: Use cached node_modules (tailwindcss)
39+
# id: cache-tailwindcss
40+
# uses: actions/cache@v3
41+
# with:
42+
# path: node_modules
43+
# key: nodeModules-${{ hashFiles('./package-lock.json') }}-${{ matrix.node-version }}-tailwindcss
44+
# restore-keys: |
45+
# nodeModules-
4646

4747
- name: Install dependencies
48-
if: steps.cache-tailwindcss.outputs.cache-hit != 'true'
48+
# if: steps.cache-tailwindcss.outputs.cache-hit != 'true'
4949
run: npm install
5050
env:
5151
CI: true

.github/workflows/nodejs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
uses: actions/setup-node@v3
2727
with:
2828
node-version: ${{ matrix.node-version }}
29-
# cache: 'npm'
30-
29+
# cache: 'npm'
30+
#
3131
# - name: Use cached node_modules
3232
# id: cache
3333
# uses: actions/cache@v3

.github/workflows/release-insiders.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
with:
2424
node-version: ${{ matrix.node-version }}
2525
registry-url: 'https://registry.npmjs.org'
26-
# cache: 'npm'
27-
26+
# cache: 'npm'
27+
#
2828
# - name: Use cached node_modules
2929
# id: cache
3030
# uses: actions/cache@v3

.github/workflows/release.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ jobs:
2323
with:
2424
node-version: ${{ matrix.node-version }}
2525
registry-url: 'https://registry.npmjs.org'
26-
cache: 'npm'
27-
28-
- name: Use cached node_modules
29-
id: cache
30-
uses: actions/cache@v3
31-
with:
32-
path: node_modules
33-
key: nodeModules-${{ hashFiles('**/package-lock.json') }}-${{ matrix.node-version }}
34-
restore-keys: |
35-
nodeModules-
26+
# cache: 'npm'
27+
#
28+
# - name: Use cached node_modules
29+
# id: cache
30+
# uses: actions/cache@v3
31+
# with:
32+
# path: node_modules
33+
# key: nodeModules-${{ hashFiles('**/package-lock.json') }}-${{ matrix.node-version }}
34+
# restore-keys: |
35+
# nodeModules-
3636

3737
- name: Install dependencies
38-
if: steps.cache.outputs.cache-hit != 'true'
38+
# if: steps.cache.outputs.cache-hit != 'true'
3939
run: npm install
4040
env:
4141
CI: true
@@ -45,8 +45,12 @@ jobs:
4545
env:
4646
CI: true
4747

48+
- name: Calculate tag
49+
run: |
50+
echo "tag_name=$(npm run calculate-tag-name --silent)" >> $GITHUB_ENV
51+
4852
- name: Publish
49-
run: npm publish
53+
run: npm publish --tag ${{ env.tag_name }}
5054
env:
5155
CI: true
5256
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"posttest": "npm run style",
2727
"generate:plugin-list": "node -r @swc/register scripts/create-plugin-list.js",
2828
"generate:types": "node -r @swc/register scripts/generate-types.js",
29-
"generate": "npm run generate:plugin-list && npm run generate:types"
29+
"generate": "npm run generate:plugin-list && npm run generate:types",
30+
"calculate-tag-name": "node scripts/calculate-tag-name.js"
3031
},
3132
"files": [
3233
"src/*",

scripts/calculate-tag-name.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
let version = process.env.npm_package_version || require('../package.json').version
2+
3+
let match = /\d+\.\d+\.\d+-(.*)\.\d+/g.exec(version)
4+
if (match) {
5+
console.log(match[1])
6+
} else {
7+
console.log('latest')
8+
}

0 commit comments

Comments
 (0)