ci: add release workflow (#318)

This commit is contained in:
Guy Ben-Aharon
2024-11-04 14:36:04 +02:00
committed by GitHub
parent b2c20459d5
commit 27b417e178
2 changed files with 71 additions and 36 deletions

59
.github/workflows/publish.yaml vendored Normal file
View File

@@ -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 }}

View File

@@ -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
- name: release-please
id: release
uses: googleapis/release-please-action@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
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/chartdb:latest
release-type: node
token: ${{ secrets.CHARTDB_OSS_RELEASE }}