From 23ae57e158cafd479c6fd6f6d47c194230660903 Mon Sep 17 00:00:00 2001 From: Brandon Casey <2381475+brandonocasey@users.noreply.github.com> Date: Tue, 24 Aug 2021 15:40:11 -0400 Subject: [PATCH] chore: update release ci and add github-release (#147) --- .github/workflows/ci.yml | 86 ++++++++++++++++------------ .github/workflows/github-release.yml | 70 ++++++++++++++++++++++ 2 files changed, 118 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/github-release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4202e48e..c900f9ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/skip-duplicate-actions@v2.1.0 + 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') }} + - 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')}} diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml new file mode 100644 index 00000000..1308470c --- /dev/null +++ b/.github/workflows/github-release.yml @@ -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