Skip to content

Commit

Permalink
feat: finalize release version (#57)
Browse files Browse the repository at this point in the history
* chore: wip change approach

* chore: prune unused imports

* chore: convert config repos to hash table

* chore: implementing sync command

* fix: history merging and commits retrieval

* feat: complete sync command

* ci: release preparation

* chore: cleanup

* refactor: derive history from git (#58)

* ci: bake permissions in executables

* refactor: derive history from git
  • Loading branch information
mark-omarov authored Jun 7, 2023
1 parent 9afe4c3 commit fae928d
Show file tree
Hide file tree
Showing 29 changed files with 600 additions and 493 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
deno-version: v1.34.x
- uses: actions/checkout@v3
- uses: cli/gh-extension-precompile@v1
with:
Expand Down
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ rules with [deno fmt][deno-fmt], and lint with [deno lint][deno-lint]. We
encourage you to [setup your IDE/Editor][deno-env] to automatically apply
formatting.

## Release

To release a new version the RC (release coordinator) should:

1. Create a new release branch
2. Bump up the version in `version.ts`
3. Commit the changes, push the branch, and prepare a PR
4. Merge the PR to main
5. Pull the changes locally, create a new tag with the correct version and push
it

[deno-install]: https://deno.land/[email protected]/getting_started/installation
[deno-env]: https://deno.land/[email protected]/getting_started/setup_your_environment
[github-prs]: https://github.com/trunklabs/gh-contribution-mate/pulls
Expand Down
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"models/repository": "./src/models/repository/mod.ts",
"models/git": "./src/models/git/mod.ts",
"models/config": "./src/models/config/mod.ts",
"utils": "./src/utils/mod.ts"
"lib": "./src/lib/mod.ts"
},
"lint": {
"files": {
Expand Down
11 changes: 11 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion script/build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
deno task compile "$@"
deno run --allow-run=deno script/compile.ts "$@"
33 changes: 18 additions & 15 deletions script/compile.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { join } from 'https://deno.land/[email protected]/path/mod.ts';

const [version] = Deno.args;
import { VERSION } from '../version.ts';

if (!version) {
if (!VERSION) {
console.error(
`[%cERROR%c] Incorrect version. %cExpected%c format "v*.*.*", %creceived%c "${version}"`,
`[%cERROR%c] Incorrect version. %cExpected%c format "v*.*.*", %creceived%c "${VERSION}"`,
'color: red',
'color: inherit',
'color: green',
Expand Down Expand Up @@ -79,26 +79,29 @@ for (const { platform, arch } of targets) {
continue;
}

const filename = `gh-contribution-mate_${platform}-${arch}`;
const filename = `gh-contribution-mate_v${VERSION}_${platform}-${arch}`;

const { success, code } = await Deno.run({
cmd: [
'deno',
const cmd = new Deno.Command('deno', {
args: [
'compile',
'--allow-run=gh,git',
'--allow-read',
'--allow-write',
`--allow-env=${
platform === Platform.WINDOWS ? 'APPDATA' : 'XDG_CONFIG_HOME,HOME'
}}`,
'-o',
join(outDir, filename),
'--target',
denoSupportedTarget,
'src/main.ts',
],
}).status();
});

if (!success) {
console.error(
`[%cERROR%c] Compilation of "${filename}" failed, status code: ${code}`,
'color: red',
'color: inherit',
);
Deno.exit(code);
const cmdOutput = await cmd.output();

if (cmdOutput.code !== 0) {
console.error(new TextDecoder().decode(cmdOutput.stderr));
Deno.exit(cmdOutput.code);
}
}
47 changes: 47 additions & 0 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { EOL } from 'std/fs';
import { basename } from 'std/path';
import { Checkbox, colors, Command } from 'cliffy';
import { getConfig, RepoType, setConfig } from '../config.ts';
import { getAuthors } from '../git.ts';

export default new Command()
.description('Add one or more local repositories for syncing.')
.arguments('<...repositories:string>')
.option('-e, --email <email:string>', 'Email to sync', { collect: true })
.action(async (_, ...repoPaths) => {
const config = await getConfig();
const mutableConfig = { ...config };

for (const repoPath of repoPaths) {
const authors = await getAuthors(repoPath);

const selectedAuthors: string[] = await Checkbox.prompt({
message: `Select authors of commits to extract from the "${
basename(repoPath)
} repository". Use arrow keys for navigation, space to select, and enter to submit.`,
options: authors.map((author) => `${author.name} <${author.email}>`),
});

const repo: RepoType = {
dir: repoPath,
authors: authors.filter((author) =>
selectedAuthors.includes(`${author.name} <${author.email}>`)
),
};

mutableConfig.repos[basename(repoPath)] = repo;
}

await setConfig(mutableConfig);

console.log(
'\xa0🎉',
colors.green('You are all set!'),
EOL.LF,
colors.green('ℹ️\xa0'),
colors.green(
'You can run the "sync" command to synchronize your commits now.',
),
colors.green('See more information with the "--help" flag.'),
);
});
166 changes: 0 additions & 166 deletions src/commands/config/config.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/commands/config/mod.ts

This file was deleted.

Loading

0 comments on commit fae928d

Please sign in to comment.