Skip to content

Commit

Permalink
feat: force fetch current tag when workflow was started from tag
Browse files Browse the repository at this point in the history
closes: #13
  • Loading branch information
DenKoren committed Feb 17, 2022
1 parent d352049 commit b7d7ff2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions actions/detect-version/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ const utils_1 = require("./utils");
const milib_1 = require("milib");
function prepareRepository(depth) {
return __awaiter(this, void 0, void 0, function* () {
// We have to do black magic here because of
// https://github.com/milaboratory/github-ci/issues/13
const refType = process.env.GITHUB_REF_TYPE;
const refName = process.env.GITHUB_REF_NAME;
if (refType === 'tag') {
yield milib_1.git.fetch({
remote: 'origin',
refSpec: `refs/tags/${refName}:refs/tags/${refName}`,
deepen: 1,
forceFlag: true
});
}
yield milib_1.git.fetchTags();
return milib_1.git.ensureHistorySize(depth);
});
Expand Down
14 changes: 14 additions & 0 deletions actions/detect-version/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ import {canonizeVersion, sanitizeVersion} from './utils'
import {git} from 'milib'

async function prepareRepository(depth: number): Promise<void> {
// We have to do black magic here because of
// https://github.com/milaboratory/github-ci/issues/13
const refType: string = process.env.GITHUB_REF_TYPE as string
const refName: string = process.env.GITHUB_REF_NAME as string

if (refType === 'tag') {
await git.fetch({
remote: 'origin',
refSpec: `refs/tags/${refName}:refs/tags/${refName}`,
deepen: 1,
forceFlag: true
})
}

await git.fetchTags()
return git.ensureHistorySize(depth)
}
Expand Down

0 comments on commit b7d7ff2

Please sign in to comment.