Skip to content

Commit

Permalink
npm/github release with github action and remove travis
Browse files Browse the repository at this point in the history
  • Loading branch information
tjenkinson committed Nov 1, 2020
1 parent 077ea60 commit 544b4ba
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 111 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,89 @@ jobs:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
NETLIFY_ACCESS_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN }}

release_github:
needs: [config, test_unit]
if: needs.config.outputs.tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: use Node.js
uses: actions/setup-node@v1
with:
node-version: "12"

- name: download build
uses: actions/download-artifact@v2
with:
name: build

- name: build release zip
run: |
zip -r dist.zip dist
- name: create github release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: upload assets to github release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist.zip
asset_name: release.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release_npm:
needs: [config, test_unit]
if: needs.config.outputs.tag || needs.config.outputs.isMainBranch == 'true'
steps:
- uses: actions/checkout@v2

- name: cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: use Node.js
uses: actions/setup-node@v1
with:
node-version: "12"

- name: download build
uses: actions/download-artifact@v2
with:
name: build

- name: install
run: |
npm ci
env:
CI: true

- name: publish to npm
run: |
./scripts/publish-npm.sh
env:
CI: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
TAG: ${{ needs.config.outputs.tag }}

test_functional_required:
needs: [config, test_unit]
if: needs.config.outputs.canUseSauce == 'true'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ coverage/

# Build
/dist
/dist.zip
/netlify
/api-docs
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

28 changes: 28 additions & 0 deletions scripts/publish-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -e

if [[ $(node ./scripts/check-already-published.js) = "not published" ]]; then
# write the token to config
# see https://docs.npmjs.com/private-modules/ci-server-config
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
if [[ -z "$TAG" ]]; then
npm publish --tag alpha
echo "Published alpha."
curl https://purge.jsdelivr.net/npm/hls.js@alpha
curl https://purge.jsdelivr.net/npm/hls.js@alpha/dist/hls-demo.js
echo "Cleared jsdelivr cache."
else
tag=$(node ./scripts/get-version-tag.js)
if [ "${tag}" = "alpha" ]; then
# alpha (previously canary) is blocked because this is handled separately on every commit
echo "alpha (previously canary) not supported as explicit tag"
exit 1
fi
echo "Publishing tag: ${tag}"
npm publish --tag "${tag}"
curl "https://purge.jsdelivr.net/npm/hls.js@${tag}"
echo "Published."
fi
else
echo "Already published."
fi
69 changes: 0 additions & 69 deletions scripts/travis.sh

This file was deleted.

0 comments on commit 544b4ba

Please sign in to comment.