From 795cb05e21e4837b063acf8e30e2f5290a4ca74e Mon Sep 17 00:00:00 2001 From: Aaron Klinker Date: Sun, 21 Jan 2024 19:09:55 -0600 Subject: [PATCH] ci: Standardize github actions with my other repos --- .github/workflows/publish.yml | 55 ---------------- .github/workflows/release.yml | 34 ++++++++++ .../workflows/{verify.yml => validate.yml} | 64 ++++++------------- 3 files changed, 52 insertions(+), 101 deletions(-) delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release.yml rename .github/workflows/{verify.yml => validate.yml} (56%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index c61613b..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Publish -on: [workflow_dispatch] - -jobs: - verify: - uses: ./.github/workflows/verify.yml - secrets: inherit - - publish: - name: Bump & Publish - runs-on: ubuntu-22.04 - needs: ['verify'] - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Grab the entire history - - - uses: pnpm/action-setup@v2.0.1 - name: Install PNPM - with: - version: 8 - - - name: Install Node - uses: actions/setup-node@v2 - with: - node-version: 18 - cache: 'pnpm' - - - name: Install Dependencies - run: pnpm install --frozen-lockfile - - - name: Create Changelog - id: changelog - uses: TriPSs/conventional-changelog-action@v3 - with: - github-token: ${{ secrets.github_token }} - output-file: 'false' - fallback-version: '1.0.0' - - - name: Publish to NPM - if: ${{ steps.changelog.outputs.skipped == 'false' }} - run: | - echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc - pnpm publish - - - name: Create Release - uses: actions/create-release@v1 - if: ${{ steps.changelog.outputs.skipped == 'false' }} - env: - GITHUB_TOKEN: ${{ secrets.github_token }} - with: - tag_name: ${{ steps.changelog.outputs.tag }} - release_name: ${{ steps.changelog.outputs.tag }} - body: ${{ steps.changelog.outputs.clean_changelog }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ac4472e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release +on: + workflow_dispatch: + +jobs: + validate: + uses: './.github/workflows/validate.yml' + + publish: + runs-on: ubuntu-22.04 + needs: + - validate + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: ./.github/actions/setup + + - name: Bump and Tag + run: | + git config user.email "github-actions@users.noreply.github.com" + git config user.name "GitHub Actions" + pnpx changelogen@latest --release + git push + git push --tags + + - name: NPM + run: | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc + pnpm publish + + - name: GitHub Release + run: pnpx changelogen@latest gh release --token ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/verify.yml b/.github/workflows/validate.yml similarity index 56% rename from .github/workflows/verify.yml rename to .github/workflows/validate.yml index 17046b4..2fb71ba 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/validate.yml @@ -1,4 +1,4 @@ -name: Verify +name: Validate on: [push, workflow_call] jobs: @@ -6,64 +6,36 @@ jobs: name: Verify Code runs-on: ubuntu-22.04 steps: - - name: Checkout Repo - uses: actions/checkout@v2 - - - uses: pnpm/action-setup@v2.0.1 - name: Install PNPM + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v2 with: version: 8 - - - name: Install Node - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: 18 - cache: 'pnpm' - - - name: Install Dependencies - run: pnpm install --frozen-lockfile - - - name: Formatting - run: pnpm format:check - - - name: Type Check - run: pnpm compile - - - name: Build - run: pnpm build - - - name: Lint - run: pnpm lint - - - name: Test - run: pnpm test - - - name: Check CLI - run: node bin/publish-extension.cjs --help + cache: pnpm + - run: pnpm install + - run: pnpm format:check + - run: pnpm compile + - run: pnpm build + - run: pnpm lint + - run: pnpm test + - run: node bin/publish-extension.cjs --help e2e-test: name: E2E Publish Test runs-on: ubuntu-22.04 steps: - - name: Checkout Repo - uses: actions/checkout@v2 - - - uses: pnpm/action-setup@v2.0.1 - name: Install PNPM + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v2 with: version: 8 - - - name: Install Node 16 - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: 18 - cache: 'pnpm' - - - name: Install Dependencies - run: pnpm install --frozen-lockfile - - - name: Publish - run: ./scripts/dev.sh all + cache: pnpm + - run: pnpm install + - run: ./scripts/dev.sh all env: CHROME_EXTENSION_ID: ${{ secrets.TEST_CHROME_EXTENSION_ID }} CHROME_CLIENT_ID: ${{ secrets.TEST_CHROME_CLIENT_ID }}