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: add a github-release github action #1182

Merged
merged 10 commits into from
Aug 17, 2021
69 changes: 69 additions & 0 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: github-release
on:
push:
tags:
# match semver versions
- "v[0-9]+.[0-9]+.[0-9]+"
brandonocasey marked this conversation as resolved.
Show resolved Hide resolved
# match semver pre-releases
- "v[0-9]+.[0-9]+.[0-9]+-*"
jobs:
github-release:
env:
NETLIFY_BASE: 'videojs-http-streaming.netlify.app'
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
gkatsev marked this conversation as resolved.
Show resolved Hide resolved

- 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 --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}}
Copy link
Member

Choose a reason for hiding this comment

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

seems like this is the default, is it worth noting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to work, from my testing on a separate repo, not sure if we need new permissions.

Copy link
Member

Choose a reason for hiding this comment

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

github adds a token by default for the current repo as well, so, it should be fine. A separate one is only needed if you need special permissions or something.

prerelease: ${{steps.pre-release-check.outputs.IS_PRE_RELEASE}}
files: |
dist/**/*.js
dist/**/*.css
Loading