Skip to content

Commit

Permalink
Merge pull request #8 from sauravhiremath/feature/npm-publish
Browse files Browse the repository at this point in the history
Feature/npm publish
  • Loading branch information
thebongy authored May 1, 2020
2 parents b38d8e0 + 1291e41 commit 4916154
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 131 deletions.
168 changes: 77 additions & 91 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,42 @@ name: Continuous integration

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
rust:
- stable
- beta
- nightly
fail-fast: false
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
- name: Setup nodejs
uses: actions/setup-node@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
node-version: '12.x'

- name: Cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all

- name: Upload Artifact (Linux/MacOS)
uses: actions/upload-artifact@v1
if: matrix.rust == 'stable' && matrix.os != 'windows-latest'
- name: Check Release Version
uses: thebongy/version-check@v1
with:
name: juno-${{matrix.os}}
path: target/release/juno

- name: Upload Artifact (Windows)
uses: actions/upload-artifact@v1
if: matrix.rust == 'stable' && matrix.os == 'windows-latest'
file: package.json
id: version_check

- name: Install dependencies
run: npm ci

- name: Linting and Test
run: npm run test:prod

- name: Run Build
run: npm run build

- name: Create tarball
run: npm pack

- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: juno-${{matrix.os}}
path: target/release/juno.exe
name: juno-node@v${{ steps.version_check.outputs.releaseVersion }}
path: ./juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz

release-master: # Publish release on push to master
# Publish release on push to master
release-master:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: build
Expand All @@ -59,45 +53,41 @@ jobs:
- run: git fetch --all --tags

- name: Check Release Version
uses: thebongy/version-check@v1
with:
file: Cargo.toml
tagFormat: v${version}
id: version_check

- name: Download Windows Artifact
uses: actions/download-artifact@v1
uses: thebongy/version-check@v1
with:
name: juno-windows-latest
path: release/windows
file: package.json
tagFormat: ${version}

- name: Download MacOS Artifact
uses: actions/download-artifact@v1
- name: Publish Release
id: create_release
uses: actions/create-release@latest
with:
name: juno-macos-latest
path: release/macos
tag_name: v${{ steps.version_check.outputs.releaseVersion }}
release_name: Juno-node@v${{ steps.version_check.outputs.releaseVersion }}
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Download Linux Artifact
uses: actions/download-artifact@v1
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: juno-ubuntu-latest
path: release/linux

- name: Rename Artifacts
run: |
mv release/windows/juno.exe release/windows/juno-${{steps.version_check.outputs.releaseVersion}}-windows.exe
mv release/macos/juno release/macos/juno-${{steps.version_check.outputs.releaseVersion}}-macos
mv release/linux/juno release/linux/juno-${{steps.version_check.outputs.releaseVersion}}-linux
name: juno-node@v${{ steps.version_check.outputs.releaseVersion }}

- name: Publish Release
uses: softprops/action-gh-release@v1
with:
files: release/**/*
tag_name: ${{steps.version_check.outputs.releaseVersion}}
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz
asset_name: juno-node@v${{ steps.version_check.outputs.releaseVersion }}.tgz
asset_content_type: application/tgz

- name: Publish to npm
run: npm publish juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

release-staging:
if: github.ref == 'refs/heads/staging'
Expand All @@ -108,42 +98,38 @@ jobs:
- run: git fetch --all --tags

- name: Check Release Version
uses: thebongy/version-check@v1
with:
file: Cargo.toml
tagFormat: v${version}-beta
id: version_check

- name: Download Windows Artifact
uses: actions/download-artifact@v1
with:
name: juno-windows-latest
path: release/windows

- name: Download MacOS Artifact
uses: actions/download-artifact@v1
uses: thebongy/version-check@v1
with:
name: juno-macos-latest
path: release/macos
file: package.json
tagFormat: ${version}

- name: Download Linux Artifact
uses: actions/download-artifact@v1
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: juno-ubuntu-latest
path: release/linux

- name: Rename Artifacts
run: |
mv release/windows/juno.exe release/windows/juno-${{steps.version_check.outputs.releaseVersion}}-windows.exe
mv release/macos/juno release/macos/juno-${{steps.version_check.outputs.releaseVersion}}-macos
mv release/linux/juno release/linux/juno-${{steps.version_check.outputs.releaseVersion}}-linux
name: juno-node@v${{ steps.version_check.outputs.releaseVersion }}

- name: Publish Release
uses: softprops/action-gh-release@v1
id: create_release
uses: actions/create-release@latest
with:
files: release/**/*
tag_name: ${{steps.version_check.outputs.releaseVersion}}
tag_name: v${{ steps.version_check.outputs.releaseVersion }}-beta
release_name: Juno-node@v${{ steps.version_check.outputs.releaseVersion }}-beta
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz
asset_name: juno-node@v${{ steps.version_check.outputs.releaseVersion }}-beta.tgz
asset_content_type: application/gzip

- name: Publish to npm
run: npm publish juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz --tag beta
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
49 changes: 32 additions & 17 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ on:
- master
- staging
- develop

name: Continuous integration (PR)

jobs:
version-check:
if: github.base_ref == 'staging' || github.base_ref == 'master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- run: git fetch --all --tags

- name: Check Release Version (staging)
Expand All @@ -21,7 +22,7 @@ jobs:
file: package.json
tagFormat: v${version}-beta
id: version_check_staging

- name: Check Release Version (master)
if: github.base_ref == 'master'
uses: thebongy/version-check@v1
Expand All @@ -30,23 +31,37 @@ jobs:
tagFormat: v${version}
id: version_check_master
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
node:
- stable
- lts
fail-fast: false
runs-on: ubuntu-latest
needs: version-check

steps:
- uses: actions/checkout@v2

- name: Install dependencies
uses: actions-rs/cargo@v1
- name: Check Release Version
uses: thebongy/version-check@v1
with:
command: npm ci

- name: Publish to npm
uses: actions-rs/cargo@v1
file: package.json
id: version_check

- name: Setup nodejs
uses: actions/setup-node@v1
with:
node-version: '12.x'

- name: Install dependencies
run: npm ci

- name: Linting and tests
run: npm run test:prod

- name: Build
run: npm build

- name: Create tar
run: npm pack

- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
command: npm publish
name: juno-node@v${{ steps.version_check.outputs.releaseVersion }}-alpha
path: ./juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz
20 changes: 0 additions & 20 deletions .travis.yml.sample

This file was deleted.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"node": ">=6.0.0"
},
"scripts": {
"lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
"lint": "tslint --project ./tsconfig/tsconfig.base.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
"prebuild": "rimraf dist",
"build": "rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src",
"start": "rollup -c rollup.config.ts -w",
Expand All @@ -31,8 +31,7 @@
"commit": "git-cz",
"semantic-release": "semantic-release",
"semantic-release-prepare": "ts-node tools/semantic-release-prepare",
"precommit": "lint-staged",
"travis-deploy-once": "travis-deploy-once"
"precommit": "lint-staged"
},
"lint-staged": {
"{src,test}/**/*.ts": [
Expand Down

0 comments on commit 4916154

Please sign in to comment.