mirror of
https://github.com/unraid/api.git
synced 2026-01-07 17:19:52 -06:00
309 lines
8.2 KiB
YAML
309 lines
8.2 KiB
YAML
name: CI - Main
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v1
|
|
|
|
- name: Add SSH deploy key
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.UNRAID_BOT_SSH_KEY }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS }}
|
|
|
|
- name: Install node v14
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 14
|
|
|
|
- name: Load npm cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Installing node deps
|
|
run: npm install
|
|
|
|
- name: Lint
|
|
run: npm run lint
|
|
|
|
coverage:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v1
|
|
|
|
- name: Add SSH deploy key
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.UNRAID_BOT_SSH_KEY }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS }}
|
|
|
|
- name: Install node v14
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 14
|
|
|
|
- name: Load npm cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Installing node deps
|
|
run: npm install
|
|
|
|
- name: Check coverage
|
|
run: npm run cover:types
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [lint,coverage]
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v1
|
|
|
|
- name: Add SSH deploy key
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.UNRAID_BOT_SSH_KEY }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS }}
|
|
|
|
- name: Install node v14
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 14
|
|
|
|
- name: Load npm cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Installing node deps
|
|
run: npm install
|
|
|
|
# See https://github.com/apollographql/subscriptions-transport-ws/issues/433
|
|
- name: Patch subscriptions-transport-ws
|
|
run: npm run patch:subscriptions-transport-ws
|
|
|
|
- name: Compile to javascript
|
|
run: npm run build
|
|
|
|
- name: Clean node_modules
|
|
run: npm run clean && curl -sf https://gobinaries.com/tj/node-prune | sh && node-prune
|
|
|
|
- name: Pack source
|
|
run: npm pack
|
|
|
|
- name: Upload source tgz to Github artifacts
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: unraid-api-source
|
|
path: ${{ github.workspace }}/*.tgz
|
|
|
|
build-binary:
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [build]
|
|
|
|
steps:
|
|
- name: Add SSH deploy key
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.UNRAID_BOT_SSH_KEY }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS }}
|
|
|
|
- name: Install node v14
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 14
|
|
|
|
- name: Load npm cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Download unraid-api source tgz
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
name: unraid-api-source
|
|
|
|
- name: Unpack unraid-api source tgz
|
|
shell: bash
|
|
run: tar xvzf ./unraid-api-*.tgz --strip 1 && rm ./unraid-api-*.tgz
|
|
|
|
- name: Load nexe cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/.nexe
|
|
key: ${{ runner.os }}-nexe
|
|
restore-keys: |
|
|
${{ runner.os }}-nexe
|
|
|
|
- name: Install nexe
|
|
run: npm i -g nexe
|
|
|
|
- name: Build binary
|
|
run: npm run build-binary
|
|
|
|
- name: Pack binary
|
|
run: npm pack
|
|
|
|
- name: Upload binary tgz to Github artifacts
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: unraid-api
|
|
path: ${{ github.workspace }}/*.tgz
|
|
|
|
pre-release:
|
|
# Only release if this is a alpha|beta|rc tag
|
|
if: |
|
|
startsWith(github.ref, 'refs/tags/v') &&
|
|
(contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc'))
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [build-binary]
|
|
|
|
steps:
|
|
- name: Add SSH deploy key
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.UNRAID_BOT_SSH_KEY }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS }}
|
|
|
|
- name: Download unraid-api binary tgz
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
name: unraid-api
|
|
|
|
- name: Create release notes
|
|
run: |
|
|
# Reverse function
|
|
reverse(){ local line;if IFS= read -r line;then reverse;printf '%s\n' "$line";fi;}; \
|
|
# Get the last release tag
|
|
LAST_RELEASE=$(git tag --list --sort=v:refname|reverse|sed -n 2p); \
|
|
# Create the release notes
|
|
RELEASE_NOTES=$(git log "$LAST_RELEASE...HEAD~1" --pretty=format:"- %s [\`%h\`](http://github.com/$ORG/$REPO/commit/%H)" --reverse) \
|
|
# Save release notes to a file
|
|
echo $RELEASE_NOTES > RELEASE_NOTES.md
|
|
|
|
- name: Create Github release
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref }}
|
|
release_name: ${{ github.ref }}
|
|
draft: false
|
|
prerelease: true
|
|
body_path: ./RELEASE_NOTES.md
|
|
|
|
- name: Upload release assets
|
|
id: upload-release-asset
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ${{ github.workspace }}/unraid-api-*.tgz
|
|
asset_name: unraid-api.tgz
|
|
asset_content_type: application/gzip
|
|
|
|
- name: Create Sentry release
|
|
uses: getsentry/action-release@v1
|
|
env:
|
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
|
|
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
|
|
with:
|
|
environment: prerelease
|
|
|
|
release:
|
|
# Only release if this is a version tag
|
|
if: |
|
|
startsWith(github.ref, 'refs/tags/v') &&
|
|
(!contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc'))
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [build-binary]
|
|
|
|
steps:
|
|
- name: Add SSH deploy key
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.UNRAID_BOT_SSH_KEY }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS }}
|
|
|
|
- name: Download unraid-api binary tgz
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
name: unraid-api
|
|
|
|
- name: Create release notes
|
|
run: |
|
|
# Reverse function
|
|
reverse(){ local line;if IFS= read -r line;then reverse;printf '%s\n' "$line";fi;}; \
|
|
# Get the last release tag
|
|
LAST_RELEASE=$(git tag --list --sort=v:refname|reverse|sed -n 2p); \
|
|
# Create the release notes
|
|
RELEASE_NOTES=$(git log "$LAST_RELEASE...HEAD~1" --pretty=format:"- %s [\`%h\`](http://github.com/$ORG/$REPO/commit/%H)" --reverse) \
|
|
# Save release notes to a file
|
|
echo $RELEASE_NOTES > RELEASE_NOTES.md
|
|
|
|
- name: Create Github release
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref }}
|
|
release_name: ${{ github.ref }}
|
|
draft: false
|
|
prerelease: false
|
|
|
|
- name: Upload release assets
|
|
id: upload-release-asset
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ${{ github.workspace }}/unraid-api-*.tgz
|
|
asset_name: unraid-api.tgz
|
|
asset_content_type: application/gzip
|
|
|
|
- name: Create Sentry release
|
|
uses: getsentry/action-release@v1
|
|
env:
|
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
|
|
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
|
|
with:
|
|
environment: production
|
|
version: ${{ github.ref }}
|