Skip to content

Commit

Permalink
chore: add ci workflows and GitHub config and init changesets
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Heywood <[email protected]>
  • Loading branch information
lachieh committed Dec 23, 2024
1 parent 068c5f7 commit fc64939
Show file tree
Hide file tree
Showing 22 changed files with 1,263 additions and 240 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
9 changes: 9 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@changesets/changelog-github", {"repo": "wasmCloud/typescript"}],
"commit": false,
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"privatePackages": {"version": true, "tag": true}
}
16 changes: 16 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CODEOWNERS

## Default to org or maintainer

* @wasmCloud/org-maintainers @wasmCloud/typescript-maintainers

## GitHub CI

.github @wasmCloud/ci-maintainers
.github/CODEOWNERS @wasmCloud/org-maintainers

## Projects

examples @wasmCloud/examples-maintainers @wasmCloud/typescript-maintainers
examples/**/README.md @wasmCloud/docs-maintainers
apps/washboard-ui @wasmCloud/washboard-maintainers @wasmCloud/typescript-maintainers
78 changes: 78 additions & 0 deletions .github/actions/ts-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Typescript / Setup

description: |
Setup a Typescript project for building and testing.
branding:
icon: settings
color: blue

inputs:
working-directory:
description: Working directory
required: false
default: ./
npm-token:
description: NPM token
required: false
default: ''
cache-key:
description: Cache key
required: false
default: 'main'

runs:
using: composite

steps:
- name: Setup Package Manager
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
corepack enable
yarn --version
- name: Setup Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6
with:
node-version-file: ${{ inputs.working-directory }}/.tool-versions
cache-dependency-path: ${{ inputs.working-directory }}/yarn.lock
cache: yarn

- name: Configure .npmrc File
if: ${{ inputs.npm-token != '' }}
shell: bash
run: |
echo "::group::Creating .npmrc file to home directory"
echo "//registry.npmjs.org/:_authToken=${{ inputs.npm-token }}" > $HOME/.npmrc
echo "registry=https://registry.npmjs.org/" >> $HOME/.npmrc
echo "always-auth=true" >> $HOME/.npmrc
echo "======================"
echo ".npmrc file contents:"
cat $HOME/.npmrc
echo "======================"
echo "::endgroup::"
- name: Cache Turbo Build
uses: actions/cache@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2
with:
path: ${{ inputs.working-directory }}/.turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}-${{ github.workflow }}-${{ inputs.cache-key || github.job || 'main' }}
restore-keys: |
${{ runner.os }}-turbo-${{ github.sha }}-${{ github.workflow }}-${{ inputs.cache-key || github.job || 'main' }}
${{ runner.os }}-turbo-${{ github.sha }}-${{ github.workflow }}-
${{ runner.os }}-turbo-${{ github.sha }}-
${{ runner.os }}-turbo-
- name: Install Dependencies
working-directory: ${{ inputs.working-directory }}
shell: bash
run: yarn install

- name: Turbo Run Summary
uses: gacts/run-and-post-run@4683764dd706df847f57b9bed39d08164bcd2690
with:
post: |
echo "::group::Turbo Run Summary"
cat ${{ inputs.working-directory }}/.turbo/runs/*.json || echo 'No Turbo Run Summary found'
echo "::endgroup::"
35 changes: 35 additions & 0 deletions .github/actions/wash-versions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: crate-versions

description: |
Get the latest versions of the `wash` CLI and `wash` Playwright tests
branding:
icon: settings
color: blue

inputs:
crate:
description: Name of the crate of which to fetch versions for
required: true

runs:
using: composite

steps:
- name: Fetch crate versions
id: fetch_versions
run: |
CRATE_NAME=${{ inputs.crate }}
# Fetch the crate information from crates.io
RESPONSE=$(curl -s -H "User-Agent: wasmCloud-github-actions/1.0 (slack.wasmcloud.com)" "https://crates.io/api/v1/crates/$CRATE_NAME")
# Extract all versions that are not yanked
ALL_VERSIONS=$(echo $RESPONSE | jq -c -r '.versions | map(select(.yanked | not)) | map(.num) | map(select(test("^[0-9]+\\.[0-9]+\\.[0-9]+$")))')
# Extract the latest 3 major versions (or minor versions if the crate is in the 0.x range)
LAST_3_VERSIONS=$(echo $ALL_VERSIONS | jq -c -r 'unique_by(if . | startswith("0.") then split(".")[1] else split(".")[0] end) | sort_by(split(".") | map(tonumber)) | reverse | .[0:3]')
echo "versions=$LAST_3_VERSIONS" >> $GITHUB_OUTPUT
shell: bash

outputs:
versions:
description: The latest 3 major versions of the crate.
value: ${{ steps.fetch_versions.outputs.versions }}
28 changes: 28 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
timezone: "America/New_York"
groups:
dev-dependencies:
dependency-type: "development"
update-types:
- "minor"
- "patch"
prod-dependencies:
dependency-type: "production"
update-types:
- "minor"
- "patch"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/.github/actions/*"
schedule:
interval: "daily"
19 changes: 19 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned # Pinned issues should stick around
- security # Security issues need to be resolved
- roadmap # Issue is captured on the wasmCloud roadmap and won't be lost
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. If this
has been closed too eagerly, please feel free to tag a maintainer so we can
keep working on the issue. Thank you for contributing to wasmCloud!
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
37 changes: 37 additions & 0 deletions .github/workflows/ci_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- main

permissions:
contents: read

concurrency:
group: washboard-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
uses: ./.github/workflows/ci_build.yml

test:
uses: ./.github/workflows/ci_test.yml

release:
uses: ./.github/workflows/ci_release.yml
# Only run on main repo, don't try to release on forks
if: github.repository == 'wasmCloud/typescript'
needs: [build, test]
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
permissions:
contents: write # Needed to commit changesets
pull-requests: write # Needed to create pull requests
id-token: write # Needed for npm provenance
36 changes: 36 additions & 0 deletions .github/workflows/ci_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build

on:
workflow_call: {}

env:
TURBO_CACHE_DIR: ./.turbo/cache
TURBO_TELEMETRY_DISABLED: true
TURBO_RUN_SUMMARY: true

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Setup Node, Yarn, and Turbo
uses: ./.github/actions/ts-setup
with:
npm-token: ${{ secrets.NPM_TOKEN }}

- name: Build
run: yarn turbo build

- name: Upload Build
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: build-assets
path: |
./**/dist/
!**/node_modules/
71 changes: 71 additions & 0 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release

on:
workflow_call:
secrets:
NPM_TOKEN:
required: false
description: NPM token for publishing packages

permissions:
contents: read

jobs:
changesets:
permissions:
contents: write # Needed to commit changesets
pull-requests: write # Needed to create pull requests
id-token: write # Needed for npm provenance

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Setup Node, Yarn, and Turbo
uses: ./.github/actions/ts-setup
with:
npm-token: ${{ secrets.NPM_TOKEN }}

- name: Build
run: yarn build

- name: Version or Publish
id: changesets
uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308
with:
title: 'chore: update versions'
commit: 'chore: update versions'
version: yarn ci:version
publish: yarn ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Parse Published Packages
if: ${{ steps.changesets.outputs.published == 'true' }}
id: parse
run: |
# Parse Published Packages
PACKAGE_VERSIONS=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -c 'map({name: .name, value: .version}) | from_entries')
echo "packageVersions=$PACKAGE_VERSIONS" >> $GITHUB_OUTPUT
echo "::group::Published Packages"
echo $PACKAGE_VERSIONS | jq
echo "::endgroup::"
outputs:
# array of objects with name and version
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
# object with package name as key and version as value
packageVersions: ${{ steps.parse.outputs.packageVersions }}

washboard-ui:
needs: [changesets]
if: ${{ contains(fromJson(needs.changesets.outputs.publishedPackages).*.name, 'washboard-ui') }}
permissions:
contents: write
uses: ./.github/workflows/release_washboard-ui.yml
with:
version: ${{ fromJson(needs.changesets.outputs.packageVersions).washboard-ui }}

Loading

0 comments on commit fc64939

Please sign in to comment.