Created
September 19, 2021 18:49
-
-
Save YonatanKra/11ec8988fe94d293e5a0445ad1a3370b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and release | |
on: | |
pull_request: | |
types: [closed] | |
jobs: | |
build-test-release: | |
if: github.event.action == 'closed' && github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.CI_REPOSITORY_ACCESS_TOKEN }} | |
- name: Setup NodeJS 14 | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 14 | |
- name: Install yarn | |
run: npm install -g yarn | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | |
- name: Cache yarn dependencies | |
uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: | | |
${{ steps.yarn-cache-dir-path.outputs.dir }} | |
**\node_modules | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
run: yarn install | |
- name: Test | |
run: | | |
RUN=CI yarn nx run-many --target=test --all | |
yarn nx run-many --target=lint --all | |
- name: Build components | |
run: | | |
yarn nx affected:build --prod --with-deps --base=main | |
- name: Raise version of affected libraries | |
run: | | |
LATEST_TAG=$(git tag -l "v*" --sort=-version:refname | head -n 1) | |
LIBS=$(yarn nx affected:libs --base=$LATEST_TAG --head=HEAD --plain | awk 'NR > 2 && $1 != "Done" { print $1 }') | |
for LIBRARY in $LIBS | |
do | |
cd ./libs/$LIBRARY | |
npm version minor --no-git-tag-version --no-push | |
echo "Bumping $LIBRARY" | |
cd .. | |
cd .. | |
done | |
npm version minor --no-git-tag-version --no-push | |
- name: get-npm-version | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@master | |
- name: Push changes | |
run: | | |
git fetch | |
git config user.email "vivid.ci@vonage.com" | |
git config user.name "Vivid CI" | |
git add --all | |
git commit -m "update versions to ${{ steps.package-version.outputs.current-version }}" | |
git push | |
- name: Tag release | |
run: | | |
git tag -a v${{ steps.package-version.outputs.current-version }} -m "tag release v${{ steps.package-version.outputs.current-version }}" | |
git push --follow-tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment