Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
setting up CI
  • Loading branch information
garronej committed May 16, 2020
1 parent 0e2cd84 commit 34e8dfa
Show file tree
Hide file tree
Showing 57 changed files with 209 additions and 1,576 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/ci.yaml
@@ -0,0 +1,78 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:

test_node:
runs-on: ubuntu-latest
if: ${{ !github.event.created }}
strategy:
matrix:
node: [ '13', '12', '11', '10', '8' ]
name: Test with Node v${{ matrix.node }}
steps:

- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- 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 branch 'latest'
id: v_latest
uses: garronej/github_actions_toolkit@master
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 master
id: v_master
uses: garronej/github_actions_toolkit@master
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 newer version'
if: ${{ !!env.PAT && steps.v_master.outputs.compare_result == '1' }}
uses: garronej/github_actions_toolkit@master
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_master.outputs.version,
github.event.repository.name
)
}}
86 changes: 86 additions & 0 deletions .github/workflows/publish.yaml
@@ -0,0 +1,86 @@
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@master
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: master
commit_author_email: ts_ci@github.com
- name: Update CHANGELOG.md
if: ${{ !!github.event.client_payload.from_version }}
uses: garronej/github_actions_toolkit@master
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: master
commit_author_email: ts_ci@github.com
exclude_commit_from_author_names_json: '["ts_ci"]'

publish_npm:
runs-on: ubuntu-latest
needs: update_changelog_and_sync_package_lock_version
steps:
- uses: actions/checkout@v2
- name: Remove branch 'latest'
continue-on-error: true
run: git push origin :latest
- name: Create the new 'latest' branch
run: |
git branch latest
git checkout latest
git push origin latest
- uses: actions/setup-node@v1
- run: npm install

- 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_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 }}
- 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 "Moving dist files to root for shorter import statements."
- name: Push changes
uses: ad-m/github-push-action@v0.5.0
with:
github_token: ${{ secrets.PAT }}
branch: latest
- name: Create Release
uses: garronej/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
tag_name: ${{ github.event.client_payload.to_version }}
release_name: Release ${{ github.event.client_payload.to_version }}
branch: latest
draft: false
prerelease: false
7 changes: 5 additions & 2 deletions .gitignore
Expand Up @@ -27,7 +27,7 @@ coverage
build/Release

# Dependency directories
/node_modules
node_modules
jspm_packages

# Optional npm cache directory
Expand All @@ -36,5 +36,8 @@ jspm_packages
# Optional REPL history
.node_repl_history

dist/test
.vscode

.DS_Store

/dist
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -4,6 +4,9 @@
</p>
<p align="center">
<i>🦕 Support Deno and release on NPM with a single codebase. 🦕</i>
<br>
<br>
<img src="https://github.com/#{USER_OR_ORG}#/#{REPO_NAME}#/workflows/ci/badge.svg">
</p>
<br>

Expand All @@ -21,7 +24,6 @@ This tool takes as input a TypeScript codebase that was meant to target node and

A way to import node modules in Deno projects. For that purpose you can try [CommonJS module Loading](https://github.com/denoland/deno/tree/master/std/node/#commonjs-module-loading)


# Motivations

Although it is quite easy to port a module to Deno it is a chore to maintain two codebases.
Expand Down
2 changes: 0 additions & 2 deletions dist/bin/denoify.d.ts

This file was deleted.

18 changes: 0 additions & 18 deletions dist/bin/denoify.js

This file was deleted.

2 changes: 0 additions & 2 deletions dist/bin/enableShortDenoImportPath.d.ts

This file was deleted.

55 changes: 0 additions & 55 deletions dist/bin/enableShortDenoImportPath.js

This file was deleted.

2 changes: 0 additions & 2 deletions dist/bin/enableShortNpmImportPath.d.ts

This file was deleted.

99 changes: 0 additions & 99 deletions dist/bin/enableShortNpmImportPath.js

This file was deleted.

0 comments on commit 34e8dfa

Please sign in to comment.