|
| 1 | +name: github-release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + # match semver versions |
| 6 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 7 | + # match semver pre-releases |
| 8 | + - "v[0-9]+.[0-9]+.[0-9]+-*" |
| 9 | +jobs: |
| 10 | + github-release: |
| 11 | + env: |
| 12 | + # Set this if you want a netlify example |
| 13 | + NETLIFY_BASE: 'https://muxjs.netlify.app/' |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v2 |
| 18 | + # We neeed to fetch the entire history as conventional-changelog needs |
| 19 | + # access to any number of git commits to build the changelog. |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: read node version from .nvmrc |
| 24 | + run: echo ::set-output name=NVMRC::$(cat .nvmrc) |
| 25 | + shell: bash |
| 26 | + id: nvm |
| 27 | + |
| 28 | + - name: setup node |
| 29 | + uses: actions/setup-node@v2 |
| 30 | + with: |
| 31 | + node-version: '${{steps.nvm.outputs.NVMRC}}' |
| 32 | + cache: npm |
| 33 | + |
| 34 | + - name: npm install |
| 35 | + run: npm i --prefer-offline --no-audit |
| 36 | + |
| 37 | + - name: build |
| 38 | + run: npm run build-prod || npm run build --if-present |
| 39 | + |
| 40 | + - name: Check if this is a pre-release |
| 41 | + run: echo ::set-output name=IS_PRE_RELEASE::$(npx -p not-prerelease is-prerelease && echo "true" || echo "false") |
| 42 | + id: pre-release-check |
| 43 | + |
| 44 | + - name: truncate CHANGELOG.md so that we can get the current versions changes only |
| 45 | + run: truncate -s 0 CHANGELOG.md |
| 46 | + |
| 47 | + - name: Generate current release changelog |
| 48 | + run: npx -p @videojs/update-changelog vjs-update-changelog --run-on-prerelease |
| 49 | + |
| 50 | + - name: get dashed package version for netlify |
| 51 | + run: echo ::set-output name=VERSION::$(node -e "process.stdout.write(require('./package.json').version.split('.').join('-'))") |
| 52 | + id: get-version |
| 53 | + shell: bash |
| 54 | + if: env.NETLIFY_BASE != '' |
| 55 | + |
| 56 | + - name: add netlify preview to release notes |
| 57 | + run: | |
| 58 | + echo "" >> CHANGELOG.md |
| 59 | + echo "[netlify preview for this version](https://v${{steps.get-version.outputs.VERSION}}--${{env.NETLIFY_BASE}})" >> CHANGELOG.md |
| 60 | + if: env.NETLIFY_BASE != '' |
| 61 | + |
| 62 | + - name: Create Github release |
| 63 | + uses: softprops/action-gh-release@v1 |
| 64 | + with: |
| 65 | + body_path: CHANGELOG.md |
| 66 | + token: ${{github.token}} |
| 67 | + prerelease: ${{steps.pre-release-check.outputs.IS_PRE_RELEASE}} |
| 68 | + files: | |
| 69 | + dist/**/*.js |
| 70 | + dist/**/*.css |
0 commit comments