Skip to content

Commit 1ac0159

Browse files
committed
Merge branch 'main' into public
2 parents 80ab333 + 0c51f76 commit 1ac0159

File tree

7 files changed

+427
-331
lines changed

7 files changed

+427
-331
lines changed

.github/workflows/makenew.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
name: Make New
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
repo:
8+
description: GitHub repository name (new-repo)
9+
required: true
10+
title:
11+
description: Package title (New Package)
12+
required: true
13+
description:
14+
description: Short package description (Foos and bars.)
15+
required: true
16+
17+
jobs:
18+
repository:
19+
name: Create new repository
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 30
22+
steps:
23+
- name: Create repository
24+
run: |
25+
gh extension install mislav/gh-repo-collab
26+
gh repo create --internal --disable-wiki --description "$DESCRIPTION" $REPO
27+
gh repo edit $REPO --delete-branch-on-merge
28+
gh repo edit $REPO --enable-projects=false
29+
gh repo-collab add $REPO $CODEOWNER --permission admin
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
32+
CODEOWNER: ${{ github.actor }}
33+
REPO: seamapi/${{ github.event.inputs.repo }}
34+
DESCRIPTION: ${{ github.event.inputs.description }}
35+
bootstrap:
36+
name: Bootstrap repository
37+
runs-on: ubuntu-latest
38+
timeout-minutes: 30
39+
needs: repository
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v3
43+
with:
44+
fetch-depth: 0
45+
token: ${{ secrets.GH_TOKEN }}
46+
- name: Import GPG key
47+
uses: crazy-max/ghaction-import-gpg@v5
48+
with:
49+
git_user_signingkey: true
50+
git_commit_gpgsign: true
51+
git_committer_name: ${{ secrets.GIT_USER_NAME }}
52+
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
53+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
54+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
55+
- name: Replace makenew boilerplate
56+
run: ./makenew.sh
57+
env:
58+
CI: 'true'
59+
mk_codeowner: ${{ github.actor }}
60+
mk_repo: ${{ github.event.inputs.repo }}
61+
mk_slug: '@seamapi/${{ github.event.inputs.repo }}'
62+
mk_title: ${{ github.event.inputs.title }}
63+
mk_description: ${{ github.event.inputs.description }}
64+
- name: Set origin
65+
run: |
66+
git remote add origin $ORIGIN
67+
git config --add --bool push.autoSetupRemote true
68+
env:
69+
ORIGIN: https://github.com/seamapi/${{ github.event.inputs.repo }}.git
70+
- name: Commit
71+
uses: stefanzweifel/git-auto-commit-action@v4
72+
with:
73+
skip_fetch: true
74+
skip_checkout: true
75+
commit_message: Replace makenew boilerplate
76+
commit_user_name: ${{ secrets.GIT_USER_NAME }}
77+
commit_user_email: ${{ secrets.GIT_USER_EMAIL }}
78+
commit_author: ${{ secrets.GIT_USER_NAME }} <${{ secrets.GIT_USER_EMAIL }}>
79+
version:
80+
name: Cut initial version
81+
runs-on: ubuntu-latest
82+
timeout-minutes: 30
83+
needs: bootstrap
84+
steps:
85+
- name: Cut version
86+
run: gh workflow run version.yml --repo $REPO --raw-field version=patch
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
89+
REPO: seamapi/${{ github.event.inputs.repo }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*.d.ts
1010
*.js
1111
*.js.map
12+
!src/**/*.d.ts
1213
!ava.config.js
1314

1415
# Build directories

README.md

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,13 @@ Bootstrap a new TypeScript module in five minutes or less.
5353

5454
### Bootstrapping a new project
5555

56-
1. Create an empty (**non-initialized**) repository on GitHub.
57-
2. Clone the main branch of this repository with
58-
```
59-
$ git clone --single-branch [email protected]:seamapi/makenew-tsmodule.git <new-ts-module>
60-
$ cd <new-ts-module>
61-
```
62-
Optionally, reset to the latest version with
63-
```
64-
$ git reset --hard <version-tag>
65-
```
66-
3. Run
67-
```
68-
$ ./makenew.sh
69-
```
70-
This will replace the boilerplate, delete itself,
71-
remove the git remote, remove upstream tags,
72-
and stage changes for commit.
73-
4. Create the required GitHub repository secrets.
74-
5. Review, commit, and push the changes to GitHub with
75-
```
76-
$ git diff --cached
77-
$ git commit -m "Replace makenew boilerplate"
78-
$ git remote add origin [email protected]:<user>/<new-node-lib>.git
79-
$ git push -u origin main
80-
```
81-
6. Ensure the GitHub action passes,
82-
then publish the initial version of the package with
83-
```
84-
$ gh workflow run version.yml --raw-field version=patch
85-
```
56+
1. [Trigger a makenew workflow from this repository][makenew workflow]. 🚀
57+
- Provide a value for each required input.
58+
- There are no defaults.
59+
- Example values are shown in parentheses.
60+
2. When the workflow completes, clone your new repo and start coding!
61+
62+
[makenew workflow]: https://github.com/seamapi/makenew-tsmodule/actions/workflows/makenew.yml
8663

8764
### Updating from this skeleton
8865

makenew.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ find_replace () {
99
}
1010

1111
sed_insert () {
12-
sed -i.sedbak -e "$2\\"$'\n'"$3"$'\n' $1
12+
sed -i.sedbak -e "$2\\""$3" $1
1313
rm $1.sedbak
1414
}
1515

@@ -37,6 +37,7 @@ stage_env () {
3737
git remote rm origin
3838
echo
3939
git rm -f makenew.sh
40+
git rm -f .github/workflows/makenew.yml
4041
echo
4142
echo 'Staging changes.'
4243
git add --all
@@ -46,22 +47,24 @@ stage_env () {
4647
}
4748

4849
makenew () {
49-
echo 'Answer all prompts.'
50-
echo 'There are no defaults.'
51-
echo 'Example values are shown in parentheses.'
52-
read -p '> Your GitHub username (my-user): ' mk_codeowner
53-
read -p '> Package title (My Package): ' mk_title
54-
read -p '> Package name (@seamapi/my-package): ' mk_slug
55-
read -p '> Short package description (Foos and bars.): ' mk_description
56-
read -p '> GitHub repository name (my-repo): ' mk_repo
50+
if [[ -z "${CI:-}" ]]; then
51+
echo 'Answer all prompts.'
52+
echo 'There are no defaults.'
53+
echo 'Example values are shown in parentheses.'
54+
read -p '> Your GitHub username (my-user): ' mk_codeowner
55+
read -p '> GitHub repository name (new-repo): ' mk_repo
56+
read -p '> Package name (@seamapi/new-package): ' mk_slug
57+
read -p '> Package title (New Package): ' mk_title
58+
read -p '> Short package description (Foos and bars.): ' mk_description
59+
fi
5760

58-
sed_delete README.md '10,103d'
61+
sed_delete README.md '10,80d'
5962
sed_insert README.md '10i' 'TODO'
6063

6164
find_replace "s/^ \"version\": \".*\"/ \"version\": \"0.0.0\"/g"
6265
find_replace "s/TypeScript Module Package Skeleton/${mk_title}/g"
6366
find_replace "s/Package skeleton for a TypeScript module\./${mk_description}/g"
64-
find_replace "s/@seambot/${mk_codeowner}/g"
67+
find_replace "s/@seambot/@${mk_codeowner}/g"
6568
find_replace "s|@seamapi/makenew-tsmodule|${mk_slug}|g"
6669
find_replace "s|makenew-tsmodule|${mk_repo}|g"
6770

0 commit comments

Comments
 (0)