Skip to content

Commit

Permalink
feat: add versioning and releases
Browse files Browse the repository at this point in the history
* feat: add release and conventional-commits GHA workflows

* feat: tag docker release with release and do not publish to npm
  • Loading branch information
njuguna-n authored Sep 10, 2024
1 parent 7a5d087 commit a528aba
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 6 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Build cht-sync containers

on:
push:
branches:
- 'main'
workflow_run:
workflows: ["release"]
types:
- completed

jobs:
build:
Expand All @@ -18,18 +19,29 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get the latest release tag
id: get_latest_release
uses: actions/github-script@v6
with:
script: |
const latestRelease = await github.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
return latestRelease.data.tag_name;
- name: Build and push couch2pg
uses: docker/build-push-action@v4
with:
context: ./couch2pg
file: ./couch2pg/Dockerfile
push: true
tags: medicmobile/cht-sync-couch2pg:latest
tags: medicmobile/cht-sync-couch2pg:${{ steps.get_latest_release.outputs.result }}

- name: Build and push dataemon
uses: docker/build-push-action@v4
with:
context: ./dbt
file: ./dbt/Dockerfile
push: true
tags: medicmobile/dataemon:latest
tags: medicmobile/dataemon:${{ steps.get_latest_release.outputs.result }}
26 changes: 26 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Conventional commits
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened

jobs:
lint_pr_title:
name: Lint PR title
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install commitlint
run: |
npm install @commitlint/config-conventional
npm install commitlint@latest
- name: Lint title
run: npx --no -- commitlint <<< "${{ github.event.pull_request.title }}"
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release
on:
push:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install Semantic Release and plugins
run: npm install -g semantic-release @semantic-release/git @semantic-release/changelog @semantic-release/github @semantic-release/commit-analyzer @semantic-release/release-notes-generator
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }}
run: npx semantic-release
22 changes: 22 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md"
]
}
],
"@semantic-release/github"
]
}
5 changes: 5 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
extends: [
'@commitlint/config-conventional'
]
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"pouchdb-core": "^8.0.1",
"sinon": "^18.0.0",
"uuid": "^9.0.1"
}
},
"private": true
}

0 comments on commit a528aba

Please sign in to comment.