diff --git a/.github/workflows/deploy-beta.yml b/.github/workflows/deploy-beta.yml deleted file mode 100644 index 9fb0b1b..0000000 --- a/.github/workflows/deploy-beta.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Deploy -on: - push: - branches: [beta-*] - workflow_dispatch: -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-deploy-beta - cancel-in-progress: false -jobs: - deploy-package-next: - runs-on: ubuntu-latest - env: - DOCKER_IMAGE: package - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - steps: - - name: Check out the repo - uses: actions/checkout@v2 - with: - # NOTE(krishan711): need full history to calculate difference - fetch-depth: 0 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Build docker image - uses: docker/build-push-action@v2 - with: - context: . - load: true - cache-from: type=gha,scope=package - cache-to: type=gha,mode=max,scope=package - tags: ${{ env.DOCKER_IMAGE }} - - name: Calculate commit count since last tag - id: vars - run: echo ::set-output name=commit_count::$(git rev-list $(git describe --tags --abbrev=0)..HEAD --count) - - name: Create .npmrc file - run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc - - name: Publish next package to npm - if: steps.vars.outputs.commit_count != '0' - run: docker run -v $(pwd)/.npmrc:/root/.npmrc $DOCKER_IMAGE make NEXT_VERSION=${{ steps.vars.outputs.commit_count }} NEXT_TYPE=${{ github.ref_name }} publish-next - \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3646fe9..b7c14fd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,20 +1,23 @@ -name: Deploy +name: Deploy Package on: push: branches: [main] + tags: ["v*"] workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-deploy cancel-in-progress: false jobs: - deploy-package-next: + deploy-package: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # Required for OIDC authentication with npm env: DOCKER_IMAGE: package - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: # NOTE(krishan711): need full history to calculate difference fetch-depth: 0 @@ -31,8 +34,37 @@ jobs: - name: Calculate commit count since last tag id: vars run: echo ::set-output name=commit_count::$(git rev-list $(git describe --tags --abbrev=0)..HEAD --count) - - name: Create .npmrc file - run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc + - name: Extract built package from Docker + run: | + docker create --name temp-container $DOCKER_IMAGE + docker cp temp-container:/app/. ./ + docker rm temp-container + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + - name: Update npm to latest + run: npm install -g npm@latest - name: Publish next package to npm - if: steps.vars.outputs.commit_count != '0' - run: docker run -v $(pwd)/.npmrc:/root/.npmrc $DOCKER_IMAGE make NEXT_VERSION=${{ steps.vars.outputs.commit_count }} publish-next + if: steps.vars.outputs.commit_count != '0' && github.ref == 'refs/heads/main' + run: npx kiba-publish --next --next-version ${{ steps.vars.outputs.commit_count }} + - name: Publish package to npm + if: startsWith(github.ref, 'refs/tags/v') + run: npm publish + create-release: + needs: deploy-package + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Create Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create ${{ github.ref_name }} \ + --title "Release ${{ github.ref_name }}" \ + --generate-notes diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index bc62eb4..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Release -on: - push: - tags: ["v*"] -jobs: - deploy-package: - runs-on: ubuntu-latest - env: - DOCKER_IMAGE: package - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Build docker image - uses: docker/build-push-action@v2 - with: - context: . - load: true - cache-from: type=gha,scope=package - cache-to: type=gha,mode=max,scope=package - tags: ${{ env.DOCKER_IMAGE }} - - name: Create .npmrc file - run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc - - name: Publish package to npm - run: docker run -v $(pwd)/.npmrc:/root/.npmrc $DOCKER_IMAGE make publish - create-release: - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - name: Create Release - uses: actions/create-release@v1 - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false