Skip to content

Commit

Permalink
CI: semver and releases (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustSamuel authored Jun 27, 2024
1 parent 5f1eca9 commit 15af1e6
Show file tree
Hide file tree
Showing 7 changed files with 8,578 additions and 2,925 deletions.
75 changes: 0 additions & 75 deletions .github/workflows/dashboard-docker.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Point of Sale - Dockerize
name: Docker Image CI

on:
workflow_dispatch:
Expand All @@ -16,39 +16,57 @@ jobs:
runs-on: ubuntu-latest
container:
image: docker:dind
strategy:
matrix:
app: [ dashboard, point-of-sale, point-of-sale-ab]
include:
- app: dashboard
env_file_main: ${{ vars.ENV_FILE_PRODUCTION }}
env_file_develop: ${{ vars.ENV_FILE_DEVELOPMENT }}
docker_tag: ${{ vars.DOCKER_TAG_DASHBOARD }}
dockerfile_path: "apps/dashboard/Dockerfile"
dir: "dashboard"
- app: point-of-sale
env_file_main: ${{ vars.ENV_FILE_PRODUCTION }}
env_file_develop: ${{ vars.ENV_FILE_DEVELOPMENT }}
docker_tag: ${{ vars.DOCKER_TAG_POS }}
dockerfile_path: "apps/point-of-sale/Dockerfile"
dir: "point-of-sale"
- app: point-of-sale-ab
env_file_main: ${{ vars.ENV_FILE_PRODUCTION }}
env_file_develop: ${{ vars.ENV_FILE_PRODUCTION }}
docker_tag: ${{ vars.DOCKER_TAG_POS }}-ab
dockerfile_path: "apps/point-of-sale/Dockerfile"
dir: "point-of-sale"

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: .
fetch-depth: 0
fetch-tags: true

- name: Set up environment - main
env:
ENV_FILE: ${{ vars.ENV_FILE_PRODUCTION }}
ENV_FILE: ${{ matrix.env_file_main }}
if: github.ref == 'refs/heads/main'
run: |
echo "${ENV_FILE}" > ./apps/point-of-sale/.env
echo "${ENV_FILE}" > ./apps/${{ matrix.dir }}/.env
- name: Set up environment - develop
env:
ENV_FILE: ${{ vars.ENV_FILE_DEVELOPMENT }}
if: github.ref == 'refs/heads/develop'
ENV_FILE: ${{ matrix.env_file_develop }}
if: github.ref != 'refs/heads/main'
run: |
echo "${ENV_FILE}" > apps/point-of-sale/.env
echo "${ENV_FILE}" > apps/${{ matrix.dir }}/.env
- name: Get Docker meta (for tags)
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
${{ vars.DOCKER_REGISTRY }}/${{ vars.DOCKER_TAG_POS }}
# generate Docker tags based on the following events/attributes
${{ vars.DOCKER_REGISTRY }}/${{ matrix.docker_tag }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -75,4 +93,4 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: "apps/point-of-sale/Dockerfile"
file: ${{ matrix.dockerfile_path }}
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
name: Point of Sale - Dockerize - AB Test
name: Release Docker Image CI

on:
workflow_dispatch:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
tags:
- 'v*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
dockerize:
release:
runs-on: ubuntu-latest
container:
image: docker:dind
steps:
- name: upgrade git
run: |
apk add --update
apk add git
git --version
strategy:
matrix:
app: [ dashboard, point-of-sale ]
include:
- app: dashboard
env_file_main: ${{ vars.ENV_FILE_PRODUCTION }}
docker_tag: ${{ vars.DOCKER_TAG_DASHBOARD }}
dockerfile_path: "apps/dashboard/Dockerfile"
- app: point-of-sale
env_file_main: ${{ vars.ENV_FILE_PRODUCTION }}
docker_tag: ${{ vars.DOCKER_TAG_POS }}
dockerfile_path: "apps/point-of-sale/Dockerfile"

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: .
fetch-depth: 0
fetch-tags: true

- name: Set up environment - main
- name: Set up environment
env:
ENV_FILE: ${{ vars.ENV_FILE_PRODUCTION }}
ENV_FILE: ${{ matrix.env_file_main }}
run: |
echo "${ENV_FILE}" > ./apps/point-of-sale/.env
- name: Set branch name with AB suffix
id: branch_name
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/}-AB)" >> $GITHUB_ENV
echo "${ENV_FILE}" > ./apps/${{ matrix.app }}/.env
- name: Get Docker meta (for tags)
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ vars.DOCKER_REGISTRY }}/${{ vars.DOCKER_TAG_POS }}
tags: ${{ env.BRANCH_NAME }}
${{ vars.DOCKER_REGISTRY }}/${{ matrix.docker_tag }}
tags: |
type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -55,7 +55,6 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Login to SudoSOS Container Registry
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
uses: docker/login-action@v2
with:
registry: ${{ vars.DOCKER_REGISTRY }}
Expand All @@ -67,10 +66,10 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64 #SudoSOS does not run on linux/arm64
push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: "apps/point-of-sale/Dockerfile"
file: ${{ matrix.dockerfile_path }}
34 changes: 34 additions & 0 deletions .github/workflows/semver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Semantic Release

on:
push:
branches:
- main

jobs:
versioning:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write
issues: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: .

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Run Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release --dry-run
15 changes: 15 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": ["package.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
Loading

0 comments on commit 15af1e6

Please sign in to comment.