Committed to master branch the updated workflows.

pull/1370/head
morpheus65535 4 years ago
parent 38a7ba522e
commit 531899fca9

@ -0,0 +1,46 @@
name: CI
on:
push:
branches: [development]
paths:
- frontend/**
- .github/workflows/ci.yml
pull_request:
branches: [development]
jobs:
Frontend:
runs-on: ubuntu-latest
env:
UI_DIRECTORY: ./frontend
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Cache node_modules
uses: actions/cache@v2
with:
path: '${{ env.UI_DIRECTORY }}/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-modules-
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: "15.x"
- name: Install dependencies
run: npm install
working-directory: ${{ env.UI_DIRECTORY }}
- name: Build
run: npm run build
working-directory: ${{ env.UI_DIRECTORY }}
- uses: actions/upload-artifact@v2
with:
name: "ui"
path: "${{ env.UI_DIRECTORY }}/build"

@ -1,39 +1,60 @@
name: release_beta_to_dev
on:
push:
branches: [ development ]
on: workflow_dispatch
jobs:
Release:
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
UI_DIRECTORY: ./frontend
ASSET_DIRECTORY: ./__builds__
FETCH_DEPTH: 15 # Should be enough
steps:
- name: Checkout source code
- name: Validate branch
if: ${{ github.ref != 'refs/heads/development' }}
run: |
echo This action can only be run on development branch, not ${{ github.ref }}
exit 1
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
fetch-depth: ${{ env.FETCH_DEPTH }}
ref: development
- name: Setup Git
run: |
git config --global user.name "github-actions" &&
git fetch --depth ${{ env.FETCH_DEPTH }} --tags
- name: Cache node_modules
uses: actions/cache@v2
with:
path: '${{ env.UI_DIRECTORY }}/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-modules-
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: '15.x'
- run: npm install -D release-it
- run: npm install -D @release-it/bumper
- id: latest_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: draft
node-version: "15.x"
- name: Install Global Tools
run: npm install -g release-it @release-it/bumper auto-changelog
- name: Install UI Dependencies
run: npm install
working-directory: ${{ env.UI_DIRECTORY }}
- name: Define LAST_VERSION environment variable
- name: Build & Stage UI
run: npm run build && git add .
working-directory: ${{ env.UI_DIRECTORY }}
- name: Save UI to Asset
run: |
echo "LAST_VERSION=${{steps.latest_release.outputs.release}}" >> $GITHUB_ENV
- name: Update version and create release
uses: TheRealWaldo/release-it@v0.2.1
with:
json-opts: '{"preRelease": true, "increment": "prepatch", "preReleaseId": "beta"}'
mkdir -p ../.${{ env.ASSET_DIRECTORY }} &&
zip -r ../.${{ env.ASSET_DIRECTORY }}/ui.zip ./ -x '*.map' -b $(mktemp -d)
working-directory: ${{ env.UI_DIRECTORY }}/build
- name: Create Release
run: release-it --ci --increment prerelease --preRelease=beta

@ -0,0 +1,62 @@
name: release_dev_to_master
on:
workflow_dispatch:
inputs:
increment:
description: "Increment Type (major, minor, patch)"
required: true
default: "patch"
jobs:
Release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
UI_DIRECTORY: ./frontend
ASSET_DIRECTORY: ./__builds__
steps:
- name: Validate branch
if: ${{ github.ref != 'refs/heads/development' }}
run: |
echo This action can only be run on development branch, not ${{ github.ref }}
exit 1
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: development
- name: Setup Git
run: git config --global user.name "github-actions"
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: "15.x"
- name: Install Global Tools
run: npm install -g release-it @release-it/bumper auto-changelog
- name: Save UI to Asset
run: |
mkdir -p ../.${{ env.ASSET_DIRECTORY }} &&
zip -r ../.${{ env.ASSET_DIRECTORY }}/ui.zip ./ -x '*.map' -b $(mktemp -d)
working-directory: ${{ env.UI_DIRECTORY }}/build
- name: Create Release
run: release-it --ci --increment ${{ github.event.inputs.increment }}
Merge:
needs: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Merge development -> master
uses: devmasx/merge-branch@v1.3.1
with:
type: now
from_branch: development
target_branch: master
github_token: ${{ secrets.GITHUB_TOKEN }}

@ -1,59 +0,0 @@
name: release_major_and_merge
on:
workflow_dispatch
jobs:
Release:
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- name: Validate branch
if: ${{ github.ref != 'refs/heads/development' }}
run: |
echo This action can only be run on development branch, not ${{ github.ref }}
exit 1
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: development
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: '15.x'
- run: npm install -D release-it
- run: npm install -D @release-it/bumper
- run: npm install -D auto-changelog
- id: latest_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: prerelease, draft
- name: Define LAST_VERSION environment variable
run: |
echo "LAST_VERSION=${{steps.latest_release.outputs.release}}" >> $GITHUB_ENV
- name: Update version and create release
uses: TheRealWaldo/release-it@v0.2.1
with:
json-opts: '{"increment": "major"}'
Merge:
needs: Release
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Merge development -> master
uses: devmasx/merge-branch@v1.3.1
with:
type: now
from_branch: development
target_branch: master
github_token: ${{ secrets.GITHUB_TOKEN }}

@ -1,59 +0,0 @@
name: release_minor_and_merge
on:
workflow_dispatch
jobs:
Release:
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- name: Validate branch
if: ${{ github.ref != 'refs/heads/development' }}
run: |
echo This action can only be run on development branch, not ${{ github.ref }}
exit 1
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: development
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: '15.x'
- run: npm install -D release-it
- run: npm install -D @release-it/bumper
- run: npm install -D auto-changelog
- id: latest_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: prerelease, draft
- name: Define LAST_VERSION environment variable
run: |
echo "LAST_VERSION=${{steps.latest_release.outputs.release}}" >> $GITHUB_ENV
- name: Update version and create release
uses: TheRealWaldo/release-it@v0.2.1
with:
json-opts: '{"increment": "minor"}'
Merge:
needs: Release
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Merge development -> master
uses: devmasx/merge-branch@v1.3.1
with:
type: now
from_branch: development
target_branch: master
github_token: ${{ secrets.GITHUB_TOKEN }}

@ -1,59 +0,0 @@
name: release_patch_and_merge
on:
workflow_dispatch
jobs:
Release:
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- name: Validate branch
if: ${{ github.ref != 'refs/heads/development' }}
run: |
echo This action can only be run on development branch, not ${{ github.ref }}
exit 1
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: development
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: '15.x'
- run: npm install -D release-it
- run: npm install -D @release-it/bumper
- run: npm install -D auto-changelog
- id: latest_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: prerelease, draft
- name: Define LAST_VERSION environment variable
run: |
echo "LAST_VERSION=${{steps.latest_release.outputs.release}}" >> $GITHUB_ENV
- name: Update version and create release
uses: TheRealWaldo/release-it@v0.2.1
with:
json-opts: '{"increment": "patch"}'
Merge:
needs: Release
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Merge development -> master
uses: devmasx/merge-branch@v1.3.1
with:
type: now
from_branch: development
target_branch: master
github_token: ${{ secrets.GITHUB_TOKEN }}

@ -0,0 +1,50 @@
name: Schedule Trigger
on:
schedule:
- cron: '0 6 * * *'
jobs:
Release-Nightly:
runs-on: ubuntu-latest
env:
GITHUB_REPO: "morpheus65535/bazarr"
GIT_BRANCH: "development"
WORKFLOW_TO_TRIGGER: "release_beta_to_dev.yaml"
steps:
- name: Get Previous Version
uses: actions/cache@v2
with:
path: ./LAST_VERSION_SAVED
key: bazarr-${{ env.GIT_BRANCH }}-${{ env.WORKFLOW_TO_TRIGGER }}-trigger
- name: Execute
run: |
echo "**** Checking branch ${{ env.GIT_BRANCH }} ****"
LATEST_VERSION=$(git ls-remote https://github.com/${{ env.GITHUB_REPO }}.git refs/heads/${{ env.GIT_BRANCH }} | cut -f1)
if [[ $? != 0 ]]; then
echo "**** Cannot get latest hash from GitHub, exiting... ****"
exit 1
fi
FILE_TO_CHECK='./LAST_VERSION_SAVED'
PREV_VERSION=0
[[ -f $FILE_TO_CHECK ]] && PREV_VERSION=$(cat $FILE_TO_CHECK)
echo "**** Previous version: $PREV_VERSION ****"
echo "**** Latest version: $LATEST_VERSION ****"
echo $LATEST_VERSION > $FILE_TO_CHECK
if [[ 16#$LATEST_VERSION -eq 16#$PREV_VERSION ]]; then
echo "**** No Changes Found ****"
else
echo "**** Changes Found ****"
if curl -sfX GET https://raw.githubusercontent.com/${{ env.GITHUB_REPO }}/${{ env.GIT_BRANCH }}/.github/workflows/${{ env.WORKFLOW_TO_TRIGGER }} > /dev/null 2>&1; then
echo "**** Workflow exists. Triggering workflow for branch ${{ env.GIT_BRANCH }} ****"
curl -iX POST \
-H "Authorization: token ${{ secrets.WF_GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "{\"ref\":\"refs/heads/${{ env.GIT_BRANCH }}\"}" \
https://api.github.com/repos/${{ env.GITHUB_REPO }}/actions/workflows/${{ env.WORKFLOW_TO_TRIGGER }}/dispatches
else
echo "**** Workflow doesn't exist! Skipping... ****"
fi
fi
Loading…
Cancel
Save