From 2b752f83d6812be62f052363bfc9aa74a09a259b Mon Sep 17 00:00:00 2001 From: JP Shilton Date: Mon, 28 Aug 2023 10:04:20 -0400 Subject: [PATCH] Add actions for building project and types --- ...d-and-publish-typescript-project-types.yml | 28 +++++++++++++ .../build-and-publish-typescript-project.yml | 25 ++++++++++++ .../build-typescript-project-types.yml | 29 ++++++++++++++ .../workflows/build-typescript-project.yml | 40 +++++++++++++++++++ .github/workflows/getsha.yml | 18 +++++++++ .github/workflows/getver.yml | 19 +++++++++ 6 files changed, 159 insertions(+) create mode 100644 .github/workflows/build-and-publish-typescript-project-types.yml create mode 100644 .github/workflows/build-and-publish-typescript-project.yml create mode 100644 .github/workflows/build-typescript-project-types.yml create mode 100644 .github/workflows/build-typescript-project.yml create mode 100644 .github/workflows/getsha.yml create mode 100644 .github/workflows/getver.yml diff --git a/.github/workflows/build-and-publish-typescript-project-types.yml b/.github/workflows/build-and-publish-typescript-project-types.yml new file mode 100644 index 0000000..080ee21 --- /dev/null +++ b/.github/workflows/build-and-publish-typescript-project-types.yml @@ -0,0 +1,28 @@ +name: Build Application + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + getver: + uses: OpenPhone/gha/.github/workflows/getver@jpTest + + build-types: + name: Build and Publish Types + runs-on: ubuntu-22.04 + needs: getver + if: github.event_name == 'push' + defaults: + run: + working-directory: ./types + steps: + - uses: OpenPhone/gha/.github/workflows/build-typescript-project-types.yml@jpTest + - name: Set Version + run: npm version "${{ needs.getver.outputs.version }}" --no-git-tag-version --no-commit-hooks + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GPR_ACCESS_TOKEN}} diff --git a/.github/workflows/build-and-publish-typescript-project.yml b/.github/workflows/build-and-publish-typescript-project.yml new file mode 100644 index 0000000..2d8ad8d --- /dev/null +++ b/.github/workflows/build-and-publish-typescript-project.yml @@ -0,0 +1,25 @@ +name: Build Application + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + getver: + uses: OpenPhone/gha/.github/workflows/getver@jpTest + + build: + name: Build and Publish Types + runs-on: ubuntu-22.04 + needs: getver + if: github.event_name == 'push' + steps: + - uses: OpenPhone/gha/.github/workflows/build-typescript-project.yml@jpTest + - name: Set Version + run: npm version "${{ needs.getver.outputs.version }}" --no-git-tag-version --no-commit-hooks + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GPR_ACCESS_TOKEN}} diff --git a/.github/workflows/build-typescript-project-types.yml b/.github/workflows/build-typescript-project-types.yml new file mode 100644 index 0000000..b72a893 --- /dev/null +++ b/.github/workflows/build-typescript-project-types.yml @@ -0,0 +1,29 @@ +name: Build Types + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + build-types: + name: Build Types + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: ./types + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '18' + registry-url: https://npm.pkg.github.com/ + scope: '@openphone' + cache: npm + - run: npm ci + env: + NODE_AUTH_TOKEN: ${{secrets.token}} + - run: npm run build + - run: npm run test diff --git a/.github/workflows/build-typescript-project.yml b/.github/workflows/build-typescript-project.yml new file mode 100644 index 0000000..b83c163 --- /dev/null +++ b/.github/workflows/build-typescript-project.yml @@ -0,0 +1,40 @@ +name: Build Application + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + build: + name: Build + runs-on: ubuntu-22.04 + steps: + - name: Setup node 18 + uses: actions/setup-node@v3 + with: + node-version: '18' + registry-url: https://npm.pkg.github.com/ + scope: '@openphone' + + - uses: actions/checkout@v3 + + - name: Cache dependencies + id: cache + uses: actions/cache@v3 + with: + path: ./node_modules + key: modules-${{ hashFiles('package-lock.json') }} + + - name: Run CI + if: steps.cache.outputs.cache-hit != 'true' + run: npm ci + env: + NODE_AUTH_TOKEN: ${{secrets.token}} + + - run: npm run lint + - run: npm run typecheck + - run: npm run build + - run: node . diff --git a/.github/workflows/getsha.yml b/.github/workflows/getsha.yml new file mode 100644 index 0000000..60fe6bf --- /dev/null +++ b/.github/workflows/getsha.yml @@ -0,0 +1,18 @@ +name: Get Version From Tag + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + getsha: + runs-on: ubuntu-22.04 + name: Get short sha + outputs: + sha: ${{ steps.short_sha.outputs.sha }} + steps: + - id: short_sha + run: echo "sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/getver.yml b/.github/workflows/getver.yml new file mode 100644 index 0000000..3dc173e --- /dev/null +++ b/.github/workflows/getver.yml @@ -0,0 +1,19 @@ +name: Get Version From Tag + +on: + workflow_call: + secrets: + token: + description: 'The GitHub/npm token' + required: true + +jobs: + getver: + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-22.04 + name: Get version from tag + outputs: + version: ${{ steps.vertag.outputs.version }} + steps: + - id: vertag + run: echo "version=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT