Skip to content

chore: add release infrastructure for v1.0.0 #1

chore: add release infrastructure for v1.0.0

chore: add release infrastructure for v1.0.0 #1

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true
type: string
env:
NODE_VERSION: '20'
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
validate:
name: Validate Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
fi
- name: Validate version matches VERSION file
run: |
FILE_VERSION=$(cat VERSION | tr -d '[:space:]')
RELEASE_VERSION="${{ steps.version.outputs.version }}"
if [ "$FILE_VERSION" != "$RELEASE_VERSION" ]; then
echo "Version mismatch: VERSION file ($FILE_VERSION) != release version ($RELEASE_VERSION)"
exit 1
fi
test:
name: Run Tests
runs-on: ubuntu-latest
needs: validate
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: firelater_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
working-directory: backend
run: npm ci
- name: Run tests
working-directory: backend
run: npm test
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/firelater_test
REDIS_URL: redis://localhost:6379
JWT_SECRET: test-secret-key-for-ci
NODE_ENV: test
build-and-push:
name: Build and Push Docker Images
runs-on: ubuntu-latest
needs: [validate, test]
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for backend
id: meta-backend
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-backend
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push backend
uses: docker/build-push-action@v5
with:
context: ./backend
push: true
tags: ${{ steps.meta-backend.outputs.tags }}
labels: ${{ steps.meta-backend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract metadata for frontend
id: meta-frontend
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push frontend
uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [validate, build-and-push]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Create release artifacts
run: |
mkdir -p release-artifacts
# Create deployment package
tar -czf release-artifacts/firelater-${{ needs.validate.outputs.version }}.tar.gz \
--exclude=node_modules \
--exclude=.git \
--exclude=.env* \
--exclude=*.log \
backend frontend docker-compose.yml docker-compose.prod.yml VERSION CHANGELOG.md README.md
# Create checksums
cd release-artifacts
sha256sum firelater-${{ needs.validate.outputs.version }}.tar.gz > checksums.txt
- name: Extract changelog for version
id: changelog
run: |
VERSION="${{ needs.validate.outputs.version }}"
# Extract the changelog section for this version
CHANGELOG=$(awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | head -n -1)
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.validate.outputs.version }}
name: FireLater ITSM Platform v${{ needs.validate.outputs.version }}
body: |
## FireLater ITSM Platform v${{ needs.validate.outputs.version }}
${{ steps.changelog.outputs.changelog }}
### Docker Images
```bash
# Pull backend image
docker pull ghcr.io/${{ github.repository }}-backend:${{ needs.validate.outputs.version }}
# Pull frontend image
docker pull ghcr.io/${{ github.repository }}-frontend:${{ needs.validate.outputs.version }}
```
### Quick Start
```bash
# Download and extract
tar -xzf firelater-${{ needs.validate.outputs.version }}.tar.gz
# Start with Docker Compose
docker-compose -f docker-compose.prod.yml up -d
```
files: |
release-artifacts/firelater-${{ needs.validate.outputs.version }}.tar.gz
release-artifacts/checksums.txt
draft: false
prerelease: false