Update only fetch all tags for publish commits (#32337)

* Update only fetch all tags for publish commits

* still fetch before yarn

* Revert "still fetch before yarn"

This reverts commit 7107f4e80f0713e74c3e56668fa585eff42b58d9.

* lint-fix

* explicitly pass commit sha

* lint-fix

* update check

* remove space in args

* Use specific argv index

* apply suggestions
This commit is contained in:
JJ Kasper 2021-12-09 16:36:18 -06:00 committed by GitHub
parent 0b1c9ec47d
commit 93ef28bbbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 2 deletions

View file

@ -42,14 +42,15 @@ jobs:
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- run: yarn install --frozen-lockfile --check-files
- run: node run-tests.js --timings --write-timings -g 1/1
- run: node ./scripts/fetch-tags.mjs ${{ github.sha }}
- name: Check docs only change
run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
id: docs-change
- run: echo ${{steps.docs-change.outputs.DOCS_CHANGE}}
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- id: check-release
run: |
if [[ $(git describe --exact-match 2> /dev/null || :) = v* ]];
@ -58,6 +59,7 @@ jobs:
else
echo "::set-output name=IS_RELEASE::false"
fi
- uses: actions/cache@v2
id: cache-build
with:

34
scripts/fetch-tags.mjs Executable file
View file

@ -0,0 +1,34 @@
import { execSync } from 'child_process'
import execa from 'execa'
;(async () => {
let commitId = process.argv[2] || ''
// parse only the last string which should be version if
// it's a publish commit
const commitMsg = execSync(
`git log -n 1 --pretty='format:%B'${commitId ? ` ${commitId}` : ''}`
)
.toString()
.trim()
const versionString = commitMsg.split(' ').pop().trim()
const publishMsgRegex = /^v\d{1,}\.\d{1,}\.\d{1,}(-\w{1,}\.\d{1,})?$/
console.log({ commitId, commitMsg, versionString })
if (publishMsgRegex.test(versionString)) {
console.log('publish commit, fetching tags')
const result = await execa(
'git',
['fetch', '--depth=1', 'origin', '+refs/tags/*:refs/tags/*'],
{
stdio: ['ignore', 'inherit', 'inherit'],
}
)
process.exit(result.exitCode)
} else {
console.log('not publish commit')
}
})()