diff --git a/.github/actions/pass.yml b/.github/actions/pass.yml new file mode 100644 index 0000000..d46144d --- /dev/null +++ b/.github/actions/pass.yml @@ -0,0 +1,84 @@ +name: 'Pass Action' +description: 'Run common checks for the project (lint, format, type check, test, build)' +outputs: + all_pass: + description: 'Whether all checks passed' + value: ${{ steps.check_results.outputs.all_pass }} + +runs: + using: 'composite' + steps: + - name: Setup Node.js 20.x for corepack + uses: actions/setup-node@v4 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org/' + scope: '@ummgoban' + + - name: Enable Corepack and Set yarn Version + shell: bash + run: | + npm install -g corepack@latest + corepack enable + + - name: Setup Node.js 20.x for yarn + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: yarn + + - name: Install dependencies + shell: bash + run: yarn install + + - name: Lint + id: lint_check + shell: bash + continue-on-error: true + run: | + yarn lint:check + echo $? > lint_result + + - name: Format + id: format_check + shell: bash + continue-on-error: true + run: | + yarn format:check + echo $? > format_result + + - name: Type Check + id: type_check + shell: bash + continue-on-error: true + run: | + yarn type-check + echo $? > type_result + + - name: Test + id: test_check + shell: bash + continue-on-error: true + run: | + yarn test + echo $? > test_result + + - name: Build + id: build + shell: bash + continue-on-error: true + run: | + yarn build + echo $? > build_result + + - name: Check Lint & Format & Type Check & Test & Build Results + id: check_results + shell: bash + run: | + if [ "$(cat lint_result)" -eq 0 ] && [ "$(cat format_result)" -eq 0 ] && [ "$(cat type_result)" -eq 0 ] && [ "$(cat test_result)" -eq 0 ] && [ "$(cat build_result)" -eq 0 ]; then + echo "all_pass=true" >> $GITHUB_OUTPUT + echo "all_pass=true" >> $GITHUB_ENV + else + echo "all_pass=false" >> $GITHUB_OUTPUT + echo "all_pass=false" >> $GITHUB_ENV + fi diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index f616d17..0c0798b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -27,68 +27,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup Node.js 20.x for corepack - uses: actions/setup-node@v4 - with: - node-version: '20.x' - registry-url: 'https://npm.pkg.github.com' - scope: '@ummgoban' + - name: Run common checks + id: pass + uses: ./.github/actions/pass.yml - - name: Enable Corepack and Set yarn Version - run: | - npm install -g corepack@latest - corepack enable - - - name: Setup Node.js 20.x for yarn - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: yarn - - - name: Install dependencies - run: yarn install - - - name: Lint - id: lint_check - continue-on-error: true - run: | - yarn lint:check - echo $? > lint_result - - - name: Format - id: format_check - continue-on-error: true - run: | - yarn format:check - echo $? > format_result - - - name: Type Check - id: type_check - continue-on-error: true - run: | - yarn type-check - echo $? > type_result - - - name: Test - id: test_check - continue-on-error: true - run: | - yarn test - echo $? > test_result - - - name: Build - id: build - continue-on-error: true - run: | - yarn build - echo $? > build_result - - - name: Check Lint & Format & Type Check & Test & Build Results - id: check_results - run: | - if [ "$(cat lint_result)" -eq 0 ] && [ "$(cat format_result)" -eq 0 ] && [ "$(cat type_result)" -eq 0 ] && [ "$(cat test_result)" -eq 0 ] && [ "$(cat build_result)" -eq 0 ]; then - echo "all_pass=true" >> $GITHUB_ENV - else - echo "all_pass=false" >> $GITHUB_ENV - exit 1 - fi + - name: Check results + if: steps.pass.outputs.all_pass != 'true' + run: exit 1 diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index d81a8ce..fe2e7ba 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -77,73 +77,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup Node.js 20.x for corepack - uses: actions/setup-node@v4 - with: - node-version: '20.x' - registry-url: 'https://registry.npmjs.org/' - scope: '@ummgoban' - - - name: Enable Corepack and Set yarn Version - run: | - npm install -g corepack@latest - corepack enable - - - name: Setup Node.js 20.x for yarn - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: yarn - - - name: Install dependencies - run: yarn install - - - name: Lint - id: lint_check - continue-on-error: true - run: | - yarn lint:check - echo $? > lint_result - - - name: Format - id: format_check - continue-on-error: true - run: | - yarn format:check - echo $? > format_result - - - name: Type Check - id: type_check - continue-on-error: true - run: | - yarn type-check - echo $? > type_result - - - name: Test - id: test_check - continue-on-error: true - run: | - yarn test - echo $? > test_result - - - name: Build - id: build - continue-on-error: true - run: | - yarn build - echo $? > build_result - - - name: Check Lint & Format & Type Check & Test & Build Results - id: check_results - run: | - if [ "$(cat lint_result)" -eq 0 ] && [ "$(cat format_result)" -eq 0 ] && [ "$(cat type_result)" -eq 0 ] && [ "$(cat test_result)" -eq 0 ] && [ "$(cat build_result)" -eq 0 ]; then - echo "all_pass=true" >> $GITHUB_ENV - else - echo "all_pass=false" >> $GITHUB_ENV - fi + - name: Run common checks + id: pass + uses: ./.github/actions/pass.yml - name: Publish - if: env.all_pass == 'true' + if: steps.pass.outputs.all_pass == 'true' run: | # create .env echo "NPM_TOKEN=${{ secrets.NPM_TOKEN }}" > .env