Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit fabec7e

Browse files
committed
Merge remote-tracking branch 'origin/master' into next
2 parents a8a12e1 + 0ca23d6 commit fabec7e

File tree

5 files changed

+166
-14
lines changed

5 files changed

+166
-14
lines changed

.github/workflows/copy-workflow.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ jobs:
5555
# See https://github.com/protocol/.github/blob/38135c75e47839623bf9b2748275d8c6167a8fa8/.github/workflows/copy-workflow.yml#L163-L168 for an example, how we used to make use of this.
5656
run: |
5757
files=${{ toJson(toJson(matrix.cfg.files)) }}
58-
files=$(echo -e "$files" | jq -c '.')
58+
extra_files=${{ toJson(toJson(matrix.cfg.extra_files)) }}
59+
files=$(echo -e "$files" "$extra_files" | jq -nc '[inputs] | add')
5960
echo "FILES=$files" >> $GITHUB_ENV
6061
- name: is initial workflow deployment
6162
# INITIAL_WORKFLOW_DEPLOYMENT=1 iff none of the files in the target repository exist yet
@@ -100,14 +101,23 @@ jobs:
100101
if: matrix.cfg.deploy_versioning
101102
uses: ./template-repo/.github/actions/copy-workflow-versioning
102103
- name: Add files
104+
env:
105+
CONTEXT: |
106+
{
107+
"config": ${{ toJSON(matrix.cfg) }},
108+
"github": {
109+
"default_branch": "${{ env.DEFAULT_BRANCH }}"
110+
}
111+
}
112+
TEMPLATE_ENGINE: s#\$\{\{\{\s*(.*?)\s*\}\}\}#`jq -cjn 'env.CONTEXT | fromjson.$1'`#ge
103113
run: |
104114
for f in $(jq -r '.[]' <<< ${{ toJson(env.FILES) }}); do
105115
echo -e "\nProcessing $f."
106116
# add DO NOT EDIT header
107117
tmp=$(mktemp)
108118
cat $TEMPLATE_REPO_DIR/$TEMPLATE_DIR/header.yml $TEMPLATE_REPO_DIR/$TEMPLATE_DIR/$f > $tmp
109-
# replace $default-branch with this repo's GitHub default branch
110-
sed -i "s:\$default-branch:${{ env.DEFAULT_BRANCH }}:g" $tmp
119+
# expand the template with values from the JSON context object
120+
perl -pi -e "$TEMPLATE_ENGINE" $tmp
111121
# create commit, if necessary
112122
commit_msg=""
113123
if [[ ! -f "$TARGET_REPO_DIR/$f" ]]; then

configs/go.json

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"deploy_go": true
1313
},
1414
"repositories": [
15+
{
16+
"target": "filecoin-project/ffi-stub"
17+
},
1518
{
1619
"target": "filecoin-project/go-address"
1720
},
@@ -39,6 +42,9 @@
3942
{
4043
"target": "filecoin-project/lassie"
4144
},
45+
{
46+
"target": "filecoin-project/lily-archiver"
47+
},
4248
{
4349
"target": "filecoin-project/snapcraft-exporter"
4450
},
@@ -48,6 +54,9 @@
4854
{
4955
"target": "ipfs-shipyard/dnslink-dnsimple"
5056
},
57+
{
58+
"target": "ipfs-shipyard/equinix-billing-tools"
59+
},
5160
{
5261
"target": "ipfs-shipyard/git-remote-ipld"
5362
},
@@ -72,9 +81,6 @@
7281
{
7382
"target": "ipfs/go-bitfield"
7483
},
75-
{
76-
"target": "ipfs/go-bitswap"
77-
},
7884
{
7985
"target": "ipfs/go-block-format"
8086
},
@@ -292,9 +298,15 @@
292298
{
293299
"target": "ipfs/iptb-plugins"
294300
},
301+
{
302+
"target": "ipfs/kuboreleaser"
303+
},
295304
{
296305
"target": "ipfs/pinbot-irc"
297306
},
307+
{
308+
"target": "ipfs/stargate"
309+
},
298310
{
299311
"target": "ipld/codec-fixtures"
300312
},
@@ -323,16 +335,18 @@
323335
"target": "ipld/go-ipld-selector-text-lite"
324336
},
325337
{
326-
"target": "ipld/go-ipldtool"
338+
"target": "ipld/go-storethehash"
327339
},
328340
{
329-
"target": "ipld/go-storethehash"
341+
"target": "ipni/caskadht"
330342
},
331343
{
332-
"target": "ipni/dhstore"
344+
"target": "ipni/dhstore",
345+
"source_ref": "next"
333346
},
334347
{
335-
"target": "ipni/go-indexer-core"
348+
"target": "ipni/go-indexer-core",
349+
"source_ref": "next"
336350
},
337351
{
338352
"target": "ipni/go-naam"
@@ -350,7 +364,8 @@
350364
"target": "ipni/indexstar"
351365
},
352366
{
353-
"target": "ipni/storetheindex"
367+
"target": "ipni/storetheindex",
368+
"source_ref": "next"
354369
},
355370
{
356371
"target": "libp2p/dht-tracer1"
@@ -506,4 +521,4 @@
506521
"target": "multiformats/ma-pipe"
507522
}
508523
]
509-
}
524+
}

configs/js.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@
4747
{ "target": "jacobheun/it-handshake" },
4848
{ "target": "libp2p/interop" },
4949
{ "target": "libp2p/js-libp2p-bootstrap" },
50+
{ "target": "libp2p/js-libp2p-cms" },
5051
{ "target": "libp2p/js-libp2p-crypto" },
5152
{ "target": "libp2p/js-libp2p-daemon" },
5253
{ "target": "libp2p/js-libp2p-delegated-content-routing" },
5354
{ "target": "libp2p/js-libp2p-delegated-peer-routing" },
5455
{ "target": "libp2p/js-libp2p-floodsub" },
5556
{ "target": "libp2p/js-libp2p-interfaces" },
5657
{ "target": "libp2p/js-libp2p-kad-dht" },
58+
{ "target": "libp2p/js-libp2p-keychain" },
5759
{ "target": "libp2p/js-libp2p-logger" },
5860
{ "target": "libp2p/js-libp2p-mdns" },
5961
{ "target": "libp2p/js-libp2p-mplex" },

templates/.github/workflows/js-test-and-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: test & maybe release
22
on:
33
push:
44
branches:
5-
- $default-branch # with #262 - ${{{ github.default_branch }}}
5+
- ${{{ github.default_branch }}}
66
pull_request:
77

88
jobs:
@@ -124,7 +124,7 @@ jobs:
124124
release:
125125
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
126126
runs-on: ubuntu-latest
127-
if: github.event_name == 'push' && github.ref == 'refs/heads/$default-branch' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
127+
if: github.event_name == 'push' && github.ref == 'refs/heads/${{{ github.default_branch }}}'
128128
steps:
129129
- uses: actions/checkout@v3
130130
with:

templates/README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Templates
2+
3+
This directory contains template files that can be expanded and copied over to the configured repositories.
4+
5+
## Header
6+
7+
The [header](header.yml) is prepended to all the files before they are copied to the target repositories.
8+
9+
## Contexts
10+
11+
You can access context information during template expansion (before copy is performed).
12+
13+
### About contexts
14+
15+
Contexts are a way to access information about the repository configuration object and repository GitHub settings. Contexts use the following syntax:
16+
17+
```
18+
${{{ <context> }}}
19+
```
20+
21+
| Context name | Type | Description |
22+
| --- | --- | --- |
23+
| `config` | `object` | Configuration object because of which the file is being copied. For more information, see [config context](#config-context) |
24+
| `github` | `object` | Information about the target repository the file is being copied to. For more information, see [github context](#github-context) |
25+
26+
The context container is generated automatically before template expansion is performed.
27+
28+
#### `config` context
29+
30+
The `config` context is the configuration object because of which the file is being copied. It is created by merging the `defaults` object with a `repository` object (from the `repositories` array) from a JSON configuration file.
31+
32+
| Property name | Type | Always present | Description |
33+
| --- | --- | --- | --- |
34+
| `config` | `object` | `true` | The top-level context. | true |
35+
| `config.files` | `array` | `true` | The files that are being copied. |
36+
| `config.extra_files` | `array` | `false` | The additional files that are also being copied. |
37+
| `config.target` | `string` | `true` | The name of the target repository in `{owner}/{repo}` format. |
38+
| `config.deploy_go` | `boolean` | `false` | Flag controling if Go specific setup should be applied to the repository. |
39+
| `config.deploy_versioning` | `boolean` | `false` | Flag controling if `versions.json` file should be deployed to the repository. |
40+
| `config.dist` | `string` | `false` | The name of the distribution built from the repository. |
41+
42+
#### `github` context
43+
44+
The `github` context contains information about the target repository the file is being copied to. It is created on the fly before template expansion is performed.
45+
46+
| Property name | Type | Always present | Description |
47+
| --- | --- | --- | --- |
48+
| `github` | `object` | `true` | The top-level context. |
49+
| `github.default_branch` | `string` | `true` | The name of the default branch of the target repository. |
50+
51+
### Examples
52+
53+
#### JSON configuration
54+
55+
```json
56+
{
57+
"defaults": {
58+
"files": [".github/workflows/automerge.yml"],
59+
"is_example": false
60+
},
61+
"repositories": [
62+
{
63+
"target": "protocol/.github-test-target",
64+
"extra_files": [".github/workflows/example.yml"],
65+
"example": {
66+
"greeting": "Hello"
67+
},
68+
"is_example": true
69+
}
70+
]
71+
}
72+
```
73+
74+
#### Context container
75+
76+
*created automatically before template expansion is performed*
77+
78+
```json
79+
{
80+
"config": {
81+
"target": "protocol/.github-test-target",
82+
"files": [".github/workflows/automerge.yml"],
83+
"extra_files": [".github/workflows/example.yml"],
84+
"example": {
85+
"greeting": "Hello"
86+
},
87+
"is_example": true
88+
},
89+
"github": {
90+
"default_branch": "master"
91+
}
92+
}
93+
```
94+
95+
#### Template
96+
97+
```yaml
98+
name: Hello
99+
on:
100+
push:
101+
branches:
102+
- ${{{ github.default_branch }}}
103+
jobs:
104+
echo:
105+
runs-on: ubuntu-latest
106+
steps:
107+
- run: echo ${{{ config.example.greeting }}}
108+
shell: bash
109+
```
110+
111+
#### Expanded template
112+
113+
```yaml
114+
name: Hello
115+
on:
116+
push:
117+
branches:
118+
- master
119+
jobs:
120+
echo:
121+
runs-on: ubuntu-latest
122+
steps:
123+
- run: echo Hello
124+
shell: bash
125+
```

0 commit comments

Comments
 (0)