diff --git a/.github/actions/action.yml b/.github/actions/action.yml new file mode 100644 index 0000000..5ae4cb5 --- /dev/null +++ b/.github/actions/action.yml @@ -0,0 +1,35 @@ +name: 'My composite action' +description: 'Checks out the repository and install' +runs: + using: 'composite' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Restore cached npm dependencies + id: cache-dependencies-restore + uses: actions/cache/restore@v4 + with: + path: | + node_modules + ~/.cache/Cypress # needed for the Cypress binary + key: ${{ runner.os }}npm-dependencies-${{ hashFiles('package-lock.json') }} + - name: Npm install + run: npm ci + shell: bash + - name: Cache npm dependencies + id: cache-dependencies-save + uses: actions/cache/save@v4 + with: + path: | + node_modules + ~/.cache/Cypress # needed for the Cypress binary + key: ${{ steps.cache-dependencies-restore.outputs.cache-primary-key }} + - name: Derive appropriate SHAs for base and head for `nx affected` commands + uses: nrwl/nx-set-shas@v4 + with: + main-branch-name: "master" diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 0000000..c078cee --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -0,0 +1,52 @@ +name: Create Releases +on: + workflow_dispatch: + +jobs: + build-and-test: + name: "Build and test" + runs-on: ubuntu-latest + permissions: + contents: "read" + actions: "read" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Npm install + uses: ./.github/actions + - run: npx nx affected -t lint test build --parallel=3 --exclude='test-npm' --base=origin/main~1 --head=origin/main +# - run: npm nx affected -t e2e-ci --parallel=1 +# - run: npm nx affected -t deploy --no-agents + + bump-version: + name: "Bump version" + needs: + - build-and-test + runs-on: ubuntu-latest + permissions: + contents: "write" + actions: "read" + id-token: "write" + timeout-minutes: 10 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Checkout and install + uses: ./.github/actions + - name: Bump version + run: | + git config user.name 'Alex H' + git config user.email 'klerick666@gmail.com' + npx nx release --skip-publish + shell: bash + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_CONFIG_PROVENANCE: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..20c6d63 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: CI +on: + pull_request: + branches: + - main + types: + - opened + - synchronize +jobs: + run-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Npm install + uses: ./.github/actions + # This line is needed for nx affected to work when CI is running on a PR + - run: git branch --track main origin/main + - run: npx nx affected -t lint test build --parallel=3 --exclude='test-npm' +# - run: npm nx affected -t e2e-ci --parallel=1 +# - run: npm nx affected -t deploy --no-agents diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..e3953d6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,31 @@ +name: Publish + +on: + workflow_run: + workflows: [ "Create Releases" ] + types: + - completed +env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} + NPM_CONFIG_PROVENANCE: true + +jobs: + publish: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + name: Publish + runs-on: ubuntu-latest + permissions: + contents: "read" + actions: "read" + id-token: "write" # needed for provenance data generation + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Npm install + uses: ./.github/actions + - run: npx nx affected -t build --parallel=3 --exclude='test-npm' --base=origin/main~1 --head=origin/main + - name: Publish packages + run: npx nx release publish + shell: bash