Skip to content

Commit

Permalink
Add github actions for github release
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamsc committed Nov 25, 2019
1 parent 745ab27 commit c608261
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 3 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deploy

on: [deployment]

jobs:
deploy:
name: Create Draft with assets
runs-on: macos-latest
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
steps:
- uses: actions/checkout@v1

- name: Set up Nodejs
uses: actions/setup-node@v1
with:
node-version: '12.x'

- name: npm install
run: |
npm install
- name: Install hub
run: brew install hub

- name: update release note
run: |
version=$(grep '"version"' package.json | sed 's/"version":[[:space:]]*"//' | sed 's/",//' | tr -d [:space:])
if [ -z "$version" ]; then
echo "taiko screencast version is not set"
exit 1
fi
echo -e "taiko-screencast v$version\n\n" > desc.txt
release_description=$(ruby -e "$(curl -sSfL https://github.com/getgauge/gauge/raw/master/build/create_release_text.rb)" taiko-screencast getgauge-contrib)
echo "$release_description" >> desc.txt
echo "Creating new draft for release v$version"
hub release create -d -F ./desc.txt "v$version"
rm -rf desc.txt
- name: 'deployment success'
if: success()
uses: 'deliverybot/status@master'
with:
state: 'success'
token: '${{ secrets.GITHUB_TOKEN }}'

- name: 'deployment failure'
if: failure()
uses: 'deliverybot/status@master'
with:
state: 'failure'
token: '${{ secrets.GITHUB_TOKEN }}'
25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: publish to NPM

on:
release:
types: [published]

jobs:
build:

runs-on: ubuntu-latest
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
NPM_TOKEN: '${{ secrets.NPM_TOKEN }}'

steps:
- uses: actions/checkout@v1
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: npm deploy
run: |
npm install
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>~/.npmrc
npm publish
18 changes: 15 additions & 3 deletions build/github_release.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#!/usr/bin/env bash
export version=$(grep '"version"' package.json | sed 's/"version":[[:space:]]*"//' | sed 's/",//' | tr -d [:space:])
curl -sSfL https://github.com/getgauge/gauge/raw/master/build/github_release.sh | sh
#!/bin/bash

if [ -z "$GITHUB_TOKEN" ]; then
echo "GITHUB_TOKEN is not set."
echo "Please create an personal access token with repo:public_repo scopes."
exit 1
fi

curl \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.ant-man-preview+json" \
-H "Content-Type: application/json" \
https://api.github.com/repos/getgauge-contrib/taiko-screencast/deployments \
--data '{"ref": "master", "required_contexts": [], "environment": "production"}'

0 comments on commit c608261

Please sign in to comment.