Skip to content

Commit

Permalink
Fix CI/CD by supporting tags (#417)
Browse files Browse the repository at this point in the history
* fix: use explicit working directory paths

* Revert "fix: use explicit working directory paths"

This reverts commit 09ef365.

* feat: support tags

* fix: rename variable
  • Loading branch information
heueristik committed Jun 16, 2023
1 parent 86208a1 commit 0ad8cad
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/contracts-versions/create-contract-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ async function checkForUncommittedChanges() {
}
}

async function getCurrentBranch() {
const {stdout} = await exec('git branch --show-current', {cwd: contractsDir});
async function getCurrentTagOrBranch() {
const {stdout} = await exec(
'git describe --exact-match --tags 2> /dev/null || git branch --show-current',
{cwd: contractsDir}
);
return stdout.trim();
}

Expand Down Expand Up @@ -66,7 +69,7 @@ async function copyContracts(versionName: string) {
async function createVersions() {
await checkForUncommittedChanges();

const currentBranch = await getCurrentBranch();
const currentTagOrBranch = await getCurrentTagOrBranch();

for (const version in commitHashes.versions) {
const versionCommit = commitHashes.versions[version] as string;
Expand All @@ -80,7 +83,7 @@ async function createVersions() {
}

// Return to the original branch
await exec(`git checkout ${currentBranch}`, {cwd: contractsDir});
await exec(`git checkout ${currentTagOrBranch}`, {cwd: contractsDir});

// Generate npm/index.ts file
const exports: string[] = [];
Expand Down

0 comments on commit 0ad8cad

Please sign in to comment.