Initial commit

This commit is contained in:
Garrone Joseph
2021-02-20 11:51:44 +01:00
commit 997a62d821
25 changed files with 13806 additions and 0 deletions

89
.github/workflows/ci.yaml vendored Normal file
View File

@ -0,0 +1,89 @@
name: ci
on:
push:
branches:
- develop
pull_request:
branches:
- develop
jobs:
test_lint:
runs-on: ubuntu-latest
if: ${{ !github.event.created }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: npm ci
- name: Making sure 'npm run lint' and 'npm run format' does not changes anything.
run: |
npm run lint:check
npm run format:check
test_node:
runs-on: ${{ matrix.os }}
needs: test_lint
strategy:
matrix:
node: [ '14', '13', '12', '11', '10', '8' ]
os: [ windows-latest, ubuntu-latest ]
name: Test with Node v${{ matrix.node }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm run build
- run: npm run test
trigger_publish:
name: Trigger publish.yaml workflow if package.json version updated ( and secrets.PAT is set ).
runs-on: ubuntu-latest
env:
PAT: ${{secrets.PAT}}
if: github.event_name == 'push' && github.event.head_commit.author.name != 'ts_ci'
needs: test_node
steps:
- name: Get version on latest
id: v_latest
uses: garronej/github_actions_toolkit@v1.9
with:
action_name: get_package_json_version
owner: ${{github.repository_owner}}
repo: ${{github.event.repository.name}}
branch: latest
compare_to_version: '0.0.0'
- name: Get version on develop
id: v_develop
uses: garronej/github_actions_toolkit@v1.9
with:
action_name: get_package_json_version
owner: ${{github.repository_owner}}
repo: ${{github.event.repository.name}}
branch: ${{ github.sha }}
compare_to_version: ${{steps.v_latest.outputs.version || '0.0.0'}}
- name: 'Trigger the ''publish'' workflow'
if: ${{ !!env.PAT && steps.v_develop.outputs.compare_result == '1' }}
uses: garronej/github_actions_toolkit@v1.9
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
action_name: dispatch_event
owner: ${{github.repository_owner}}
repo: ${{github.event.repository.name}}
event_type: publish
client_payload_json: |
${{
format(
'{{"from_version":"{0}","to_version":"{1}","repo":"{2}"}}',
steps.v_latest.outputs.version,
steps.v_develop.outputs.version,
github.event.repository.name
)
}}

106
.github/workflows/publish.yaml vendored Normal file
View File

@ -0,0 +1,106 @@
on:
repository_dispatch:
types: publish
jobs:
update_changelog_and_sync_package_lock_version:
name: Update CHANGELOG.md and make sure package.json and package-lock.json versions matches.
runs-on: ubuntu-latest
steps:
- name: Synchronize package.json and package-lock.json version if needed.
uses: garronej/github_actions_toolkit@v1.9
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
action_name: sync_package_and_package_lock_version
owner: ${{github.repository_owner}}
repo: ${{github.event.client_payload.repo}}
branch: develop
commit_author_email: ts_ci@github.com
- name: Update CHANGELOG.md
if: ${{ !!github.event.client_payload.from_version }}
uses: garronej/github_actions_toolkit@v1.9
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
action_name: update_changelog
owner: ${{github.repository_owner}}
repo: ${{github.event.client_payload.repo}}
branch_behind: latest
branch_ahead: develop
commit_author_email: ts_ci@github.com
exclude_commit_from_author_names_json: '["ts_ci"]'
publish:
runs-on: ubuntu-latest
needs: update_changelog_and_sync_package_lock_version
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: develop
- name: Remove .github directory, useless on 'latest' branch
run: rm -r .github
- name: Remove branch 'latest'
continue-on-error: true
run: |
git branch -d latest || true
git push origin :latest
- name: Create the new 'latest' branch
run: |
git branch latest
git checkout latest
- uses: actions/setup-node@v1
- run: npm ci
- run: npm run enable_short_import_path
env:
DRY_RUN: "0"
- name: (DEBUG) Show how the files have been moved to enable short import
run: ls -lR
- name: Publishing on NPM
run: |
if [ "$(npm show . version)" = "$VERSION" ]; then
echo "This version is already published"
exit 0
fi
if [ "$NPM_TOKEN" = "" ]; then
echo "Can't publish on NPM, You must first create a secret called NPM_TOKEN that contains your NPM auth token. https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets"
false
fi
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
npm publish
rm .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
VERSION: ${{ github.event.client_payload.to_version }}
- name: Commit changes
run: |
git config --local user.email "ts_ci@github.com"
git config --local user.name "ts_ci"
git add -A
git commit -am "Enabling shorter import paths [automatic]"
- run: git push origin latest
- name: Release body
id: id_rb
run: |
if [ "$FROM_VERSION" = "" ]; then
echo "::set-output name=body::🚀"
else
echo "::set-output name=body::📋 [CHANGELOG](https://github.com/$OWNER/$REPO/blob/$REF/CHANGELOG.md)"
fi
env:
FROM_VERSION: ${{ github.event.client_payload.from_version }}
OWNER: ${{github.repository_owner}}
REPO: ${{github.event.client_payload.repo}}
REF: v${{github.event.client_payload.to_version}}
- name: Create Release
uses: garronej/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
tag_name: v${{ github.event.client_payload.to_version }}
release_name: Release v${{ github.event.client_payload.to_version }}
branch: latest
draft: false
prerelease: false
body: ${{ steps.id_rb.outputs.body }}

View File

@ -0,0 +1,65 @@
name: template_initialization
on:
create:
branches:
- develop
jobs:
template_initialization:
runs-on: ubuntu-latest
steps:
- name: Checking availability for module name ${{github.event.repository.name}} on NPM.
id: id1
uses: garronej/github_actions_toolkit@v1.9
with:
action_name: is_well_formed_and_available_module_name
module_name: ${{github.event.repository.name}}
- name: Checks results
run: |
if [ "$IS_VALID_NODE_MODULE_NAME" = "false" ]; then
echo $MODULE_NAME" is not a valid node module name"
false
fi
if [ "$IS_AVAILABLE_ON_NPM" = "false" ]; then
echo "WARNING: There is already a NPM module named "$MODULE_NAME", if you are not the owner consider picking another name"
fi
true
env:
MODULE_NAME: ${{github.event.repository.name}}
IS_VALID_NODE_MODULE_NAME: ${{steps.id1.outputs.is_valid_node_module_name}}
IS_AVAILABLE_ON_NPM: ${{steps.id1.outputs.is_available_on_npm}}
- uses: actions/checkout@v2
- run: mv README.template.md README.md
- run: mv LICENSE.template LICENSE
- name : String replace
id: id2
uses: garronej/github_actions_toolkit@v1.9
with:
action_name: string_replace
input_string: ${{github.event.repository.name}}
search_value: '-'
replace_value: '_'
- name: Replace tokens in README.MD and package.json
uses: cschleiden/replace-tokens@v1
with:
files: '["README.md","package.json","LICENSE","package-lock.json"]'
env:
REPO_NAME: ${{ github.event.repository.name }}
USER_OR_ORG: ${{ github.repository_owner }}
DESC: ${{ github.event.repository.description }}
REPO_NAME_NO_DASHES: ${{ steps.id2.outputs.replace_result }}
- name: Remove this workflow, it only needs to be run once.
run: rm .github/workflows/template_initialization.yaml
- name: Commit files
run: |
git config --local user.email "ts_ci@github.com"
git config --local user.name "ts_ci"
git commit -am "Replacing the template's placeholders"
- name: Push changes
uses: ad-m/github-push-action@v0.5.0
with:
github_token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
branch: develop