From 88a385db55fb8273ea520b328f636b28d822d192 Mon Sep 17 00:00:00 2001 From: zeshanziya Date: Wed, 25 Sep 2024 10:31:49 +0000 Subject: [PATCH] chore: automate package publishing Signed-off-by: zeshanziya --- .github/workflows/release.yml | 33 ++++++++++++++++++++++++++++++++- package.json | 4 +++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 244c8dc..256cea2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,10 +20,41 @@ jobs: with: node-version: 18 + - name: Install Yarn + run: npm install -g yarn + + - name: Get Yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: Cache Yarn dependencies + uses: actions/cache@v4 + id: yarn-cache + with: + path: | + **/node_modules + ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-bs-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn-bs- + - name: Install Dependencies run: yarn install --immutable - - name: Create Release Pull Request + - name: Run linter + run: yarn lint + + - name: Run Code formatting check + run: yarn prettier:check + + - name: Run tests + run: yarn test + + - name: Create Release Pull Request or Publish to NPM uses: changesets/action@v1 + with: + version: yarn release:version + publish: yarn release:publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 3fab784..c3a899f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,9 @@ "lint": "backstage-cli repo lint --since origin/main", "lint:all": "backstage-cli repo lint", "prettier:check": "prettier --check .", - "new": "backstage-cli new --scope internal" + "new": "backstage-cli new --scope internal", + "release:version": "changeset version && prettier --write '{packages,plugins}/*/{package.json,CHANGELOG.md}' && yarn install", + "release:publish": "tsc && build:all && changeset publish" }, "workspaces": { "packages": [