diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index bb64281..8fb18c2 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -13,19 +13,27 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Updated to the latest major version - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: 20.9.0 + node-version: '20.x' registry-url: 'https://registry.npmjs.org/' + cache: 'yarn' - name: Install dependencies - run: npm install + run: yarn install + + - name: Cache Node Modules + uses: actions/cache@v3 + with: + path: | + **/node_modules + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Release - run: npx semantic-release + run: yarn release:plugin env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..78364b0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,43 @@ +name: Publish Project + +on: + push: + branches: [ release ] + pull_request: + branches: [ release ] + +jobs: + quality: + + runs-on: ${{ matrix.os }} + + strategy: + matrix: + node-version: [20.x] + os: [ubuntu-latest] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: yarn install + - run: yarn test + + publish: + runs-on: ubuntu-latest + if: ${{ github.ref == 'refs/heads/release' }} + needs: [quality] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: yarn install + - run: yarn release:plugin + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/update-main.yml b/.github/workflows/update-main.yml index 888590a..f940a8d 100644 --- a/.github/workflows/update-main.yml +++ b/.github/workflows/update-main.yml @@ -1,28 +1,15 @@ -name: Publish to npm with Yarn - +name: main branch update on: - push: - branches: - - main - pull_request: - branches: - - main - + release: + types: [published] jobs: - publish: + build: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup Node.js - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 20.9.0 - - - name: Install dependencies - run: npm install - - - name: Run tests with Yarn - run: npm test + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + - run: yarn + - run: yarn test diff --git a/package.json b/package.json index 7896251..d0b211e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "husky": "husky", "commit": "commit", "test": "vitest", - "coverage": "vitest run --coverage" + "coverage": "vitest run --coverage", + "release:plugin": "yarn workspace gatsby-source-hubspot-nodes semantic-release" }, "packageManager": "yarn@3.3.1" } diff --git a/packages/plugin/package.json b/packages/plugin/package.json index cb00b38..36b3c86 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -13,7 +13,8 @@ "clean": "del-cli dist", "build": "tsc", "develop": "tsc --watch", - "prepare": "npm run clean && npm run build" + "prepare": "npm run clean && npm run build", + "semantic-release": "semantic-release --branches main" }, "keywords": [ "gatsby", @@ -29,6 +30,7 @@ "del-cli": "^5.1.0", "gatsby": "^5.13.3", "gatsby-plugin-utils": "^4.13.1", + "semantic-release": "^23.0.6", "typescript": "^5.4.3" }, "peerDependencies": { @@ -39,6 +41,6 @@ }, "repository": { "type": "git", - "url": "https://github.com/samcyn/gatsby-source-hubspot-nodes" + "url": "https://github.com/samcyn/gatsby-source-hubspot-nodes.git" } }