Skip to content

Commit 918c12d

Browse files
committed
build: Add workflow scripts
1 parent 11374ad commit 918c12d

File tree

9 files changed

+227
-0
lines changed

9 files changed

+227
-0
lines changed

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: [TimothyJones] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
# patreon: # Replace with a single Patreon username
5+
# open_collective: # Replace with a single Open Collective username
6+
# ko_fi: # Replace with a single Ko-fi username
7+
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
# liberapay: # Replace with a single Liberapay username
10+
# issuehunt: # Replace with a single IssueHunt username
11+
# otechie: # Replace with a single Otechie username
12+
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
# Node / npm
9+
- package-ecosystem: "npm" # See documentation for possible values
10+
directory: "/" # Location of package manifests
11+
versioning-strategy: increase
12+
schedule:
13+
interval: "weekly"
14+
15+
# Maintain dependencies for GitHub Actions
16+
- package-ecosystem: "github-actions"
17+
directory: "/"
18+
schedule:
19+
interval: "weekly"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build + test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
node-version: [18.x, 20.x]
18+
os: [macos-latest, ubuntu-latest, windows-latest]
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
- run: npm install -g npm@latest
28+
- run: bash ci/build-and-test.sh
29+
shell: bash
30+
env:
31+
NODE_VERSION: ${{ matrix.node-version }}
32+
FORCE_COLOR: true
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependency Review Action
2+
#
3+
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
4+
#
5+
# Source repository: https://github.com/actions/dependency-review-action
6+
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
7+
name: 'Dependency Review'
8+
on: [pull_request]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
dependency-review:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: 'Checkout Repository'
18+
uses: actions/checkout@v4
19+
- name: 'Dependency Review'
20+
uses: actions/dependency-review-action@v4
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
name: Run Release Please
11+
jobs:
12+
release-please:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: google-github-actions/release-please-action@v4
16+
id: release
17+
with:
18+
token: ${{ secrets.RATE_TOKEN_GH }}
19+
20+
outputs:
21+
release_created: ${{ steps.release.outputs.release_created }}
22+
tag_name: ${{ steps.release.outputs.tag_name }}
23+
24+
publish:
25+
needs: [release-please]
26+
runs-on: ubuntu-latest
27+
steps:
28+
# The logic below handles the npm publication:
29+
- name: Checkout Repository
30+
if: ${{ needs.release-please.outputs.release_created }}
31+
uses: actions/checkout@v4
32+
- name: Setup Node
33+
uses: actions/setup-node@v4
34+
if: ${{ needs.release-please.outputs.release_created }}
35+
with:
36+
node-version: 18
37+
registry-url: 'https://registry.npmjs.org'
38+
- name: Build Packages
39+
if: ${{ needs.release-please.outputs.release_created }}
40+
run: ci/build-and-test.sh
41+
env:
42+
NODE_VERSION: 18
43+
FORCE_COLOR: true
44+
45+
# Release Please has already incremented versions and published tags, so we just
46+
# need to publish all unpublished versions to NPM here
47+
# See: https://github.com/lerna/lerna/tree/main/commands/publish#bump-from-package
48+
# - name: Publish to NPM
49+
# if: ${{ needs.release-please.outputs.release_created }}
50+
# env:
51+
# NODE_AUTH_TOKEN: ${{secrets.CONTRACT_CASE_NPM}}
52+
# run: npx lerna publish from-package --no-push --no-private --yes

ci/build-and-test.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash -eu
2+
set -eu # We do this twice so that winadows github runners will properly read them
3+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running
4+
# shellcheck source=lib/robust-bash.sh
5+
. "$SCRIPT_DIR"/lib/robust-bash.sh
6+
7+
npm install # We can't do npm ci because lerna has optional dependencies :(
8+
9+
npm run format:check
10+
npm run build
11+
npm run lint
12+

ci/lib/robust-bash.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash -eu
2+
if [ -z "${LIB_ROBUST_BASH_SH:-}" ]; then
3+
LIB_ROBUST_BASH_SH=included
4+
5+
function error {
6+
echo "${1:-}"
7+
}
8+
9+
function log {
10+
echo "🔵 ${1:-}"
11+
}
12+
13+
function debug_log {
14+
if [ ! -z "${LIB_ROBUST_BASH_DEBUG:-}" ]; then
15+
echo "🔎 ${1:-}"
16+
fi
17+
}
18+
19+
function warn {
20+
echo "🟡 ${1:-}"
21+
}
22+
23+
# Check to see that we have a required binary on the path
24+
# and fail the script if it is not present
25+
function require_binary {
26+
if [ -z "${1:-}" ]; then
27+
error "${FUNCNAME[0]} requires an argument"
28+
exit 1
29+
fi
30+
31+
if ! [ -x "$(command -v "$1")" ]; then
32+
error "The required executable '$1' is not on the path."
33+
exit 1
34+
fi
35+
}
36+
37+
# Check to see that we have a required environment variable set,
38+
# and fail the script if it is not set.
39+
#
40+
# Optionally, a second argument can be provided to display
41+
# a helpful message before failing
42+
function require_env_var {
43+
var_name="${1:-}"
44+
if [ -z "${!var_name:-}" ]; then
45+
error "The required environment variable ${var_name} is empty"
46+
if [ ! -z "${2:-}" ]; then
47+
echo " - $2"
48+
fi
49+
exit 1
50+
fi
51+
}
52+
fi

ci/release.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash -eu
2+
set -eu # We do this twice so that winadows github runners will properly read them
3+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running
4+
# shellcheck source=lib/robust-bash.sh
5+
. "$SCRIPT_DIR"/lib/robust-bash.sh
6+
7+
8+
echo "release.sh is NOT IMPLEMENTED"
9+
exit 1

release-please-config.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"plugins": [{ "type": "node-workspace", "merge": false }],
3+
4+
"group-pull-request-title-pattern": "chore: release ${component} ${scope} ${version}",
5+
"pull-request-title-pattern": "chore: release ${component} ${scope} ${version}",
6+
"bump-minor-pre-major": true,
7+
"bump-patch-for-minor-pre-major": true,
8+
"separate-pull-requests": true,
9+
"packages": {
10+
".": {
11+
"release-type": "node",
12+
"component": "example-extractor",
13+
"bump-minor-pre-major": true,
14+
"bump-patch-for-minor-pre-major": true,
15+
"changelog-path": "CHANGELOG.md"
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)