diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 000000000..857708415 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,59 @@ +name: Publish + +on: + push: + tags: + - 'v*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Use Node.js 22.x + uses: actions/setup-node@v4 + with: + node-version: 22.x + + - name: Log in to the Container registry + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run lint + + - name: Build project + run: npm run build + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c6cce8c9f..188984160 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,44 +2,20 @@ name: Release on: push: - branches: [main] + branches: + - main + +permissions: + contents: write + pull-requests: write jobs: - build-and-publish: + release: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Use Node.js 22.x - uses: actions/setup-node@v4 - with: - node-version: 22.x - - - name: Log in to the Container registry - uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Install dependencies - run: npm ci - - - name: Lint - run: npm run lint - - - name: Build project - run: npm run build - - - name: Build and push Docker image - uses: docker/build-push-action@v6 + - name: release-please + id: release + uses: googleapis/release-please-action@v4 with: - context: . - push: true - tags: ghcr.io/${{ github.repository_owner }}/chartdb:latest + release-type: node + token: ${{ secrets.CHARTDB_OSS_RELEASE }}