Skip to content

Commit af7d826

Browse files
ci: added release and build pipeline
1 parent 239c69a commit af7d826

7 files changed

Lines changed: 396 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
issues: write
12+
pull-requests: write
13+
packages: write
14+
15+
jobs:
16+
release:
17+
name: Semantic Release
18+
runs-on: ubuntu-latest
19+
outputs:
20+
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
21+
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
persist-credentials: false
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
34+
- name: Install dependencies
35+
run: |
36+
npm install -g semantic-release@latest
37+
npm install -g @semantic-release/git
38+
npm install -g @semantic-release/changelog
39+
npm install -g @semantic-release/github
40+
npm install -g @semantic-release/npm
41+
42+
- name: Semantic Release
43+
id: semantic
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
run: |
47+
npx semantic-release > semantic-release-output.log 2>&1 || true
48+
cat semantic-release-output.log
49+
50+
if grep -q "Published release" semantic-release-output.log; then
51+
echo "new_release_published=true" >> $GITHUB_OUTPUT
52+
VERSION=$(grep "Published release" semantic-release-output.log | sed -n 's/.*Published release \([0-9.]*\).*/\1/p')
53+
echo "new_release_version=$VERSION" >> $GITHUB_OUTPUT
54+
else
55+
echo "new_release_published=false" >> $GITHUB_OUTPUT
56+
fi
57+
58+
docker:
59+
name: Build and Push Docker Image
60+
runs-on: ubuntu-latest
61+
needs: release
62+
if: needs.release.outputs.new_release_published == 'true'
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
67+
- name: Set up Docker Buildx
68+
uses: docker/setup-buildx-action@v3
69+
70+
- name: Login to GitHub Container Registry
71+
uses: docker/login-action@v3
72+
with:
73+
registry: ghcr.io
74+
username: ${{ github.actor }}
75+
password: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Extract metadata
78+
id: meta
79+
uses: docker/metadata-action@v5
80+
with:
81+
images: ghcr.io/${{ github.repository }}/lighthouse
82+
tags: |
83+
type=semver,pattern={{version}},value=${{ needs.release.outputs.new_release_version }}
84+
type=semver,pattern={{major}}.{{minor}},value=${{ needs.release.outputs.new_release_version }}
85+
type=semver,pattern={{major}},value=${{ needs.release.outputs.new_release_version }}
86+
type=raw,value=latest
87+
88+
- name: Build and push
89+
uses: docker/build-push-action@v5
90+
with:
91+
context: ./lighthouse
92+
file: ./lighthouse/Dockerfile
93+
push: true
94+
tags: ${{ steps.meta.outputs.tags }}
95+
labels: ${{ steps.meta.outputs.labels }}
96+
cache-from: type=gha
97+
cache-to: type=gha,mode=max

.releaserc.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/changelog",
7+
[
8+
"@semantic-release/npm",
9+
{
10+
"npmPublish": false
11+
}
12+
],
13+
[
14+
"@semantic-release/git",
15+
{
16+
"assets": ["CHANGELOG.md", "package.json"],
17+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
18+
}
19+
],
20+
"@semantic-release/github"
21+
]
22+
}

lighthouse/.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
node_modules
22
.svelte-kit
33
build
4+
.git
45
.env
56
.env.*
67
!.env.example
78
*.log
89
.DS_Store
10+
Thumbs.db
11+
coverage
12+
.vscode
13+
.idea
14+
*.swp
15+
*.swo
16+
dist

lighthouse/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM node:20-alpine AS builder
2+
3+
RUN apk add --no-cache python3 make g++
4+
5+
WORKDIR /app
6+
7+
COPY package*.json ./
8+
9+
RUN npm ci
10+
11+
COPY . .
12+
13+
RUN npm run build
14+
15+
FROM node:20-alpine
16+
17+
RUN apk add --no-cache python3 make g++
18+
19+
WORKDIR /app
20+
21+
COPY --from=builder /app/build ./build
22+
COPY --from=builder /app/package*.json ./
23+
24+
RUN npm ci --omit=dev
25+
26+
RUN mkdir -p /app/data
27+
28+
EXPOSE 3000
29+
30+
ENV NODE_ENV=production
31+
ENV PORT=3000
32+
33+
CMD ["node", "build"]

0 commit comments

Comments
 (0)