Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update release ci and add github-release #147

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 48 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,72 @@ name: ci
on: [push, pull_request]

jobs:
should-skip:
continue-on-error: true
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should-skip-job: ${{steps.skip-check.outputs.should_skip}}
steps:
- id: skip-check
uses: fkirc/[email protected]
with:
github_token: ${{github.token}}

ci:
env:
BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }}
BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}
runs-on: ${{ matrix.os }}
needs: should-skip
if: ${{needs.should-skip.outputs.should-skip-job != 'true' || github.ref == 'refs/heads/main'}}
strategy:
# TODO: test IE 11, Legacy Edge, and New Edge on windows-latest
# test Safari on macos-latest
fail-fast: false
matrix:
os: [ubuntu-latest]

test-type: ['unit', 'coverage']
env:
BROWSER_STACK_USERNAME: ${{secrets.BROWSER_STACK_USERNAME}}
BROWSER_STACK_ACCESS_KEY: ${{secrets.BROWSER_STACK_ACCESS_KEY}}
CI_TEST_TYPE: ${{matrix.test-type}}
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
${{ runner.os }}-
- name: checkout code
uses: actions/checkout@v2

- name: Read .nvmrc
- name: read node version from .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
shell: bash
id: nvm

- name: Install ffmpeg/pulseaudio for firefox on linux w/o browserstack
- name: update apt cache on linux w/o browserstack
run: sudo apt-get update

- name: install ffmpeg/pulseaudio for firefox on linux w/o browserstack
run: sudo apt-get install ffmpeg pulseaudio
if: ${{ startsWith(matrix.os, 'ubuntu') && !env.BROWSER_STACK_USERNAME }}

- name: start pulseaudio for firefox on linux w/o browserstack
run: pulseaudio -D
if: ${{ startsWith(matrix.os, 'ubuntu') && !env.BROWSER_STACK_USERNAME }}

- name: Setup node
uses: actions/setup-node@v1
- name: setup node
uses: actions/setup-node@v2
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- run: npm i --prefer-offline --no-audit
node-version: '${{steps.nvm.outputs.NVMRC}}'
cache: npm

# run safari on macos
- name: Run Mac test
run: npm run test -- --browsers Safari
if: ${{ startsWith(matrix.os, 'macos') }}
# turn off the default setup-node problem watchers...
- run: echo "::remove-matcher owner=eslint-compact::"
- run: echo "::remove-matcher owner=eslint-stylish::"
- run: echo "::remove-matcher owner=tsc::"

# only run ie 11 on windows
- name: Run Windows test
run: npm run test -- --browsers IE
if: ${{ startsWith(matrix.os, 'windows') }}
Comment on lines -47 to -57
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like this is something we want to keep?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want the os --browsers thing no. Old version of the ci script operated under the assumption that we would forgo browserstack at some point. Eventually we decided that we can make that jump later and removed all the code for os specific browser runs.

- name: npm install
run: npm i --prefer-offline --no-audit

# run chrome/firefox or browserstack in linux
- name: Run linux test
- name: run npm test
uses: GabrielBB/xvfb-action@v1
with:
run: npm test
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: npm run test

- name: coverage
uses: codecov/codecov-action@v1
with:
token: ${{secrets.CODECOV_TOKEN}}
files: './test/dist/coverage/coverage-final.json'
fail_ci_if_error: true
if: ${{startsWith(env.CI_TEST_TYPE, 'coverage')}}
70 changes: 70 additions & 0 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: github-release
on:
push:
tags:
# match semver versions
- "v[0-9]+.[0-9]+.[0-9]+"
# match semver pre-releases
- "v[0-9]+.[0-9]+.[0-9]+-*"
jobs:
github-release:
env:
# Set this if you want a netlify example
NETLIFY_BASE: ''
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# We neeed to fetch the entire history as conventional-changelog needs
# access to any number of git commits to build the changelog.
with:
fetch-depth: 0

- name: read node version from .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
shell: bash
id: nvm

- name: setup node
uses: actions/setup-node@v2
with:
node-version: '${{steps.nvm.outputs.NVMRC}}'
cache: npm

- name: npm install
run: npm i --prefer-offline --no-audit

- name: build
run: npm run build-prod || npm run build --if-present

- name: Check if this is a pre-release
run: echo ::set-output name=IS_PRE_RELEASE::$(npx -p not-prerelease is-prerelease && echo "true" || echo "false")
id: pre-release-check

- name: truncate CHANGELOG.md so that we can get the current versions changes only
run: truncate -s 0 CHANGELOG.md

- name: Generate current release changelog
run: npx -p @videojs/update-changelog vjs-update-changelog --run-on-prerelease

- name: get dashed package version for netlify
run: echo ::set-output name=VERSION::$(node -e "process.stdout.write(require('./package.json').version.split('.').join('-'))")
id: get-version
shell: bash
if: env.NETLIFY_BASE != ''

- name: add netlify preview to release notes
run: |
echo "" >> CHANGELOG.md
echo "[netlify preview for this version](https://v${{steps.get-version.outputs.VERSION}}--${{env.NETLIFY_BASE}})" >> CHANGELOG.md
if: env.NETLIFY_BASE != ''

- name: Create Github release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.md
token: ${{github.token}}
prerelease: ${{steps.pre-release-check.outputs.IS_PRE_RELEASE}}
files: |
dist/**/*.js
dist/**/*.css