Skip to content

Commit

Permalink
ci: add release workflow (chartdb#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
guyb1 authored Nov 4, 2024
1 parent b2c2045 commit 27b417e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 36 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
48 changes: 12 additions & 36 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 27b417e

Please sign in to comment.