Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI/CD by supporting tags #417

Merged
merged 4 commits into from
Jun 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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