From af06b7068aaab3d3066e1e204ee93091dd11ba34 Mon Sep 17 00:00:00 2001 From: Taylor Beseda Date: Thu, 25 Jan 2024 18:52:51 -0700 Subject: [PATCH] wrangle some github actions --- .github/workflows/binary-build.yml | 77 +++++++++++++----------------- .github/workflows/build.yml | 76 +++++++++++------------------ .github/workflows/npm-publish.yml | 49 +++++++++++++++++++ .github/workflows/publish-now.yml | 32 ------------- package.json | 3 +- 5 files changed, 112 insertions(+), 125 deletions(-) create mode 100644 .github/workflows/npm-publish.yml delete mode 100644 .github/workflows/publish-now.yml diff --git a/.github/workflows/binary-build.yml b/.github/workflows/binary-build.yml index ca5e674..0c55e38 100644 --- a/.github/workflows/binary-build.yml +++ b/.github/workflows/binary-build.yml @@ -15,51 +15,40 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - node-version: [ 18.x ] os: [ windows-latest, ubuntu-latest, macOS-latest, self-hosted ] # Go steps: - - name: Check out repo - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - name: Env - run: | - echo "Event name: ${{ github.event_name }}" - echo "Git ref: ${{ github.ref }}" - echo "GH actor: ${{ github.actor }}" - echo "SHA: ${{ github.sha }}" - VER=`node --version`; echo "Node ver: $VER" - VER=`npm --version`; echo "npm ver: $VER" - - - name: Install Globals - run: npm install -g @enhance/arc-plugin-enhance - - - name: Install - run: npm install - - - name: Build - run: npm run build - env: - BUILD_ALL: false - - - name: Test - run: npm run test:integration - env: - BINARY_ONLY: true - CI: true - - - name: Notify - uses: homoluctus/slatify@master - if: github.ref == 'refs/heads/main' && failure() - with: - type: ${{ job.status }} - job_name: '*Test*' - url: ${{ secrets.SLACK_WEBHOOK }} - commit: true - token: ${{ secrets.GITHUB_TOKEN }} + - name: Check out repo + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Env + run: | + echo "Event name: ${{ github.event_name }}" + echo "Git ref: ${{ github.ref }}" + echo "GH actor: ${{ github.actor }}" + echo "SHA: ${{ github.sha }}" + VER=`node --version`; echo "Node ver: $VER" + VER=`npm --version`; echo "npm ver: $VER" + + - name: Install Globals + run: npm install -g @enhance/arc-plugin-enhance + + - name: Install + run: npm install + + - name: Build + run: npm run build + env: + BUILD_ALL: false + + - name: Test + run: npm run test:integration + env: + BINARY_ONLY: true + CI: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b3ed31..a43d72f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,44 +20,33 @@ jobs: # Go steps: + - name: Check out repo + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Env + run: | + echo "Event name: ${{ github.event_name }}" + echo "Git ref: ${{ github.ref }}" + echo "GH actor: ${{ github.actor }}" + echo "SHA: ${{ github.sha }}" + VER=`node --version`; echo "Node ver: $VER" + VER=`npm --version`; echo "npm ver: $VER" - - name: Check out repo - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - name: Env - run: | - echo "Event name: ${{ github.event_name }}" - echo "Git ref: ${{ github.ref }}" - echo "GH actor: ${{ github.actor }}" - echo "SHA: ${{ github.sha }}" - VER=`node --version`; echo "Node ver: $VER" - VER=`npm --version`; echo "npm ver: $VER" - - - name: Install Globals - run: npm install -g @enhance/arc-plugin-enhance - - - name: Install - run: npm install - - - name: Test - run: npm test - env: - CI: true - - - name: Notify - uses: homoluctus/slatify@master - if: github.ref == 'refs/heads/main' && failure() - with: - type: ${{ job.status }} - job_name: '*Test*' - url: ${{ secrets.SLACK_WEBHOOK }} - commit: true - token: ${{ secrets.GITHUB_TOKEN }} + - name: Install Globals + run: npm install -g @enhance/arc-plugin-enhance + + - name: Install + run: npm install + + - name: Test + run: npm test + env: + CI: true # ----- Only git tag testing + release deployment beyond this point ----- # @@ -87,7 +76,7 @@ jobs: - name: Publish 'latest' (aka production) build if: startsWith(github.ref, 'refs/tags/v') - run: npm run publish + run: npm run publish-binary env: DEPLOY: prod AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -98,7 +87,7 @@ jobs: - name: Publish 'main' (aka canary) build if: github.ref == 'refs/heads/main' - run: npm run publish + run: npm run publish-binary env: DEPLOY: main AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -147,12 +136,3 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} CF_DISTRO: ${{ secrets.CF_DISTRO }} LATEST_API: ${{ secrets.LATEST_API }} - - - name: Notify - uses: homoluctus/slatify@master - with: - type: ${{ job.status }} - job_name: '*Deploy*' - url: ${{ secrets.SLACK_WEBHOOK }} - commit: true - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..f960df6 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,49 @@ +name: Publish to NPM + +on: [ push, pull_request ] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + node-version: [ 16, 18, 20 ] + os: [ windows-latest, ubuntu-latest, macOS-latest ] + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - run: npm install + + - name: test + run: npm run test:module + + publish: + needs: test + if: startsWith(github.ref, 'refs/tags/v') || + github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: lts/* + registry-url: https://registry.npmjs.org/ + + - name: Publish @RC to npm + if: contains(github.ref, 'RC') + run: npm publish --tag RC + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish @latest to npm + if: contains(github.ref, 'RC') == false + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish-now.yml b/.github/workflows/publish-now.yml deleted file mode 100644 index 7388d57..0000000 --- a/.github/workflows/publish-now.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: npm publish - -on: [ push, pull_request] - -jobs: - publish-now: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: lts/* - registry-url: https://registry.npmjs.org/ - - - name: Env - run: | - echo "Event name: ${{ github.event_name }}" - echo "Git ref: ${{ github.ref }}" - echo "GH actor: ${{ github.actor }}" - echo "SHA: ${{ github.sha }}" - VER=`node --version`; echo "Node ver: $VER" - VER=`npm --version`; echo "npm ver: $VER" - - - run: npm i - - - run: npm run test:module - - - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 6391cf5..e9a0752 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,11 @@ "test:unit": "cross-env tape 'test/unit/**/*-test.js' | tap-arc", "test:integration": "cross-env NODE_ENV=testing tape 'test/integration/**/*-test.js' | tap-arc", "test:integration:slow": "cross-env NODE_ENV=testing tape 'test/integration/**/*-test-slow.js' | tap-arc", + "test:module": "MODULE_ONLY=true npm run test", "coverage": "nyc --reporter=lcov --reporter=text npm run test:unit", "lint": "eslint . --fix", "build": "cross-env scripts/binary-config && npx pkg scripts --compress GZip && rm -f commit", - "publish": "BUILD_ALL=true npm run build && scripts/publish", + "publish-binary": "BUILD_ALL=true npm run build && scripts/publish", "deploy": "scripts/deploy" }, "license": "Apache-2.0",