Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
airtonix committed Jun 19, 2024
0 parents commit fc8b63c
Show file tree
Hide file tree
Showing 17 changed files with 653 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/actions/setup-npm-publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Setup Npm Publishing

description: Configures Npm for Publishing in Github Actions

inputs:
NpmRegistryUrl:
description: 'The registry url to use for the install'
default: 'https://registry.npmjs.org'
NpmRcFile:
description: 'The path to the .npmrc file'
default: '~/.npmrc'

runs:
using: 'composite'

steps:
- name: create .npmrc
shell: bash
env:
NPM_REGISTRY_URL: ${{ inputs.NpmRegistryUrl }}
NPM_RC_FILE: ${{ inputs.NpmRcFile }}
# Create .npmrc file
# This file is used to authenticate with the npm registry
# The NPM_AUTH_TOKEN is an envvar that will be used later, we
# don't interpolate it here now, hence the escaped $.
# When used in the npm publish command, it's able to
# interpolate the value from Environment Variables.
run: ${{ github.action_path }}/create-npmrc.sh $NPM_REGISTRY_URL $NPM_RC_FILE
21 changes: 21 additions & 0 deletions .github/actions/setup-npm-publish/create-npmrc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# if 1st argument is not provided, exit
if [ -z "$1" ]; then
echo "Arg 1: Registry URL is required"
exit 1
fi

# if 2nd argument is not provided, exit
if [ -z "$2" ]; then
echo "Arg 2: npmrc output file is required"
exit 1
fi

# strip http(s):// from registry URL
domain="${1//http:\/\//}"
domain="${domain//https:\/\//}"

echo "//${domain}/:_authToken=\${NPM_AUTH_TOKEN}" >"$2"
echo "registry=${1}" >>"$2"
echo "always-auth=true" >>"$2"
54 changes: 54 additions & 0 deletions .github/actions/setup-tooling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# setup-tooling

Installs ASDF with plugins

## Requirements

- a `.tool-versions` file in the root of the repo

## Usage

```yml
Release:

runs-on: ubuntu-latest

permissions:
contents: write
deployments: write

steps:

- uses: actions/checkout@v3

- name: Setup tooling
uses: ./.github/actions/setup-tooling
env:
# if you use an asdf plugin called "something" and its not in the shortname repo: https://github.com/asdf-vm/asdf-plugins
# then it gets listed here as `ASDF_PLUGIN_URL_<pluginname>: the plugin repo`
ASDF_PLUGIN_URL_something: https://get.thething/asdf-plugin
```
- installs asdf plugins for each item listed in your `.tools-version`
- if one of your plugins isn't on the official asdf list, then provide the
install url by defining an ENVVAR of `ASDF_PLUGIN_URL_pluginname=url`

### Custom ASDF Setup command

Normally you'd have a `setup.sh` in the root of the repo. If it's somewhere else,
then specify with your own version of the setup command:

```yml
Release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup tooling
uses: ./.github/actions/setup-tooling
with:
SetupCommand: ./your/path/to/your/asdf/setup.sh
```
65 changes: 65 additions & 0 deletions .github/actions/setup-tooling/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Setup Asdf

description: provisions tooling

inputs:
SetupCommand:
description: "Command to run"
required: false
default: ./setup.bash

runs:
using: "composite"

steps:
- name: Ensure setup command available
shell: bash
env:
SETUP_COMMAND: ${{inputs.SetupCommand}}
run: |
if [ ! -f ${SETUP_COMMAND} ]; then
echo "🛑 Missing action input SetupCommand."
exit 1
fi
- uses: actions/cache@v3
id: online-asdf-cache
if: ${{ !env.ACT }}
with:
path: ~/.asdf
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-
#
# This step serves as an interop layer between the online and offline
# when online, we use github cache and this step will report if the cache was hit
# when offline, we use act and this step will report that the cache was not hit
- name: act cache interop
shell: bash
id: cache
run: |
if [ "${{ env.ACT }}" = "true" ]; then
echo "OFFLINE: no cache"
echo "cache-hit=false" >> $GITHUB_OUTPUT
elif [ "${{ steps.online-asdf-cache.outputs.cache-hit }}" = "true" ]; then
echo "ONLINE: cache available"
echo "cache-hit=${{ steps.online-asdf-cache.outputs.cache-hit }}" >> $GITHUB_OUTPUT
fi
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
if: steps.cache.outputs.cache-hit != 'true'
shell: bash

- name: asdf install
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
env:
SETUP_COMMAND: ${{inputs.SetupCommand}}
run: ${SETUP_COMMAND}

- name: set asdf path
shell: bash
run: |
echo "$HOME/.asdf/bin" >> $GITHUB_PATH
echo "$HOME/.asdf/shims" >> $GITHUB_PATH
37 changes: 37 additions & 0 deletions .github/actions/setup-yarn/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Install Nodejs dependencies with Yarn

description: installs dependancies

inputs:
AuthToken:
description: 'Auth token for the registry'
required: false
RegistryUrl:
description: 'The registry url to use for the install'
required: false

runs:
using: 'composite'

steps:
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
shell: bash

- name: Cache node modules
id: yarn-cache
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
shell: bash
env:
HUSKY_SKIP_INSTALL: '1'
HUSKY: '0'
run: yarn install --immutable
24 changes: 24 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Auto Approve Dependabot PRs

on:
pull_request_target:
types: [labeled]
pull_request:
types: [labeled]

jobs:
AutoUpdateDependabot:
name: Auto-Approve and enable Auto-Merge for all Dependabot PRs
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies')
steps:
# Enable auto-merge *before* issuing an approval.
- name: Enable Github Automerge
uses: alexwilson/enable-github-automerge-action@main
with:
github-token: '${{ secrets.RELEASE_PLEASE_TOKEN }}'

# We "trust" dependabot updates (this still requires all other checks to pass!)
- uses: hmarr/auto-approve-action@5d04a5ca6da9aeb8ca9f31a5239b96fc3e003029
with:
github-token: '${{ secrets.RELEASE_PLEASE_TOKEN }}'
27 changes: 27 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'LintPrTitle'

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
ValidatePrTitle:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
fix
feat
chore
docs
build
content
38 changes: 38 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Pr

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Needed for nx-set-shas within nx-cloud-main.yml, when run on the master branch
permissions:
actions: read
contents: read

jobs:
Check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Asdf
uses: ./.github/actions/setup-tooling

- name: Install Node Modules
uses: ./.github/actions/setup-yarn

- name: lint
run: just lint

- name: test
run: just test

- name: docs
run: just docs

- name: build
run: just build
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Release

on:
push:
branches:
- master

env:
HUSKY: 0 # https://typicode.github.io/husky/how-to.html#ci-server-and-docker

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

# Needed for nx-set-shas within nx-cloud-main.yml, when run on the master branch
permissions:
actions: read
contents: write
deployments: write
pull-requests: write
id-token: write

jobs:
Process:
runs-on: ubuntu-latest
outputs:
releases_created: ${{ steps.release-please.outputs.releases_created }}
steps:
- uses: google-github-actions/release-please-action@v4
id: release-please
with:
token: ${{secrets.RELEASE_PLEASE_TOKEN}}
- name: Print Release Data
run: |
echo 'Release Data:'
echo '''
${{ toJSON(steps.release-please.outputs) }}
'''
Deploy:
needs: Process
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Asdf
uses: ./.github/actions/setup-tooling

- name: Yarn
uses: ./.github/actions/setup-yarn

- name: Configure Publishing
uses: ./.github/actions/setup-npm-publish
with:
NpmRegistryUrl: https://registry.npmjs.org/
NpmRcFile: .npmrc

- name: Preflight
run: |
just lint
just types
just test
just build
- if: ${{ needs.Process.outputs.releases_created == 'true' }}
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: just stage=production publish

- if: ${{ needs.Process.outputs.releases_created == 'false' }}
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: just stage=development publish
8 changes: 8 additions & 0 deletions .plugin-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
action-validator https://github.com/mpalmer/action-validator.git 8df3ccb
asdf-plugin-manager https://github.com/asdf-community/asdf-plugin-manager.git 6fc3faa
direnv https://github.com/asdf-community/asdf-direnv.git a2219c2
just https://github.com/olofvndrhr/asdf-just.git 93771e1
nodejs https://github.com/asdf-vm/asdf-nodejs.git c5b7c40
shellcheck https://github.com/luizm/asdf-shellcheck.git 780d78d
yarn https://github.com/twuni/asdf-yarn.git 376c540
just https://github.com/olofvndrhr/asdf-just.git 93771e1
2 changes: 2 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
4 changes: 4 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
just 1.25.2
nodejs 20.12.1
yarn 1.22.19
shellcheck 0.9.0
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @zenobius/remark-nomnoml

A remark plugin that renders nomnoml diagrams inline as svg.
Loading

0 comments on commit fc8b63c

Please sign in to comment.