Skip to content

Commit

Permalink
ci: release fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Papirniy committed Feb 2, 2022
1 parent 8f53ce1 commit c309838
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 97 deletions.
93 changes: 30 additions & 63 deletions .github/workflows/build.pr.yaml β†’ .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
name: PR
name: Build all packages

on:
push:
branches:
- master
- '!release'
pull_request:

env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
TATUM_API_KEY: ${{ secrets.TATUM_API_KEY }}

jobs:
pr:
main:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'Release v') }}
if: ${{ github.event_name != 'pull_request' }}
steps:
- uses: actions/checkout@v2
name: Checkout [main]
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand All @@ -38,93 +42,56 @@ jobs:
- run: npx nx affected --target=lint --parallel --max-parallel=3
- run: npx nx affected --target=build --parallel --max-parallel=3
- run: yarn test:ci
# - name: SonarCloud Scan
# uses: SonarSource/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

publish:
needs: [ pr ]
if: ${{ github.head_ref == 'release' && !contains(github.event.head_commit.message, 'Release v') }}
- run: npx nx-cloud stop-all-agents
- name: SonarCloud Scan
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
pr:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.PAT_GITHUB_ADMIN }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Git config
run: |
git config --local user.name github-actions
git config --local user.email [email protected]
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/setup-node@v1
with:
node-version: '14'

- run: yarn --ignore-scripts --frozen-lockfile
- run: npx nx-cloud start-ci-run
- run: yarn build:all

- run: echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" > ~/.npmrc
- run: npm config set tag-version-prefix ''

- name: Publish packages
run: yarn --ignore-scripts release:current
env:
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB_ADMIN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

stop-agents-after-pr:
if: ${{ github.head_ref != 'release' }}
needs: [ pr ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: '14'
- run: yarn --ignore-scripts --frozen-lockfile
- run: npx nx-cloud stop-all-agents

stop-agents-after-publish:
if: ${{ github.head_ref == 'release' && !contains(github.event.head_commit.message, 'Release v') }}
needs: [ publish ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
main-branch-name: 'master'
- uses: actions/setup-node@v1
with:
node-version: '14'
- run: yarn --ignore-scripts --frozen-lockfile
- run: npx nx-cloud start-ci-run
- run: npx nx affected --target=lint --parallel --max-parallel=3
- run: npx nx affected --target=build --parallel --max-parallel=3
- run: yarn test:ci
- run: npx nx-cloud stop-all-agents
- name: SonarCloud Scan
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

agents:
runs-on: ubuntu-latest
name: Agent 1
timeout-minutes: 60
strategy:
matrix:
agent: [ 1, 2, 3 ]
agent: [1, 2, 3]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,63 +1,72 @@
name: MASTER
name: Publish all packages

on:
push:
branches:
- master

env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
TATUM_API_KEY: ${{ secrets.TATUM_API_KEY }}
- release

jobs:
main:
agents:
if: "!contains(github.event.head_commit.message, 'Release v')"
runs-on: ubuntu-latest
name: Agent 1
timeout-minutes: 60
strategy:
matrix:
agent: [ 1, 2, 3 ]
steps:
- uses: actions/checkout@v2
name: Checkout [main]
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: '14'
- run: yarn
- name: Start Nx Agent ${{ matrix.agent }}
run: npx nx-cloud start-agent

publish:
if: "!contains(github.event.head_commit.message, 'Release v')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout
with:
token: ${{ secrets.PAT_GITHUB_ADMIN }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Git config
run: |
git config --local user.name github-actions
git config --local user.email [email protected]
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: 'master'
- uses: actions/setup-node@v1
with:
node-version: '14'

- run: yarn --ignore-scripts --frozen-lockfile

- run: npx nx-cloud start-ci-run
- run: npx nx affected --target=lint --parallel --max-parallel=3
- run: npx nx affected --target=build --parallel --max-parallel=3
- run: yarn test:ci
- run: yarn build:all
- run: npx nx-cloud stop-all-agents
- name: SonarCloud Scan
uses: SonarSource/[email protected]

- run: echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" > ~/.npmrc
- run: npm config set tag-version-prefix ''

- name: Publish packages
run: yarn --ignore-scripts release:current
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB_ADMIN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

agents:
runs-on: ubuntu-latest
name: Agent 1
timeout-minutes: 60
strategy:
matrix:
agent: [1, 2, 3]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14'
- run: yarn
- name: Start Nx Agent ${{ matrix.agent }}
run: npx nx-cloud start-agent

0 comments on commit c309838

Please sign in to comment.