Skip to content
30 changes: 30 additions & 0 deletions .github/scripts/create-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = async ({ github, context }) => {
const newTag = process.env.NEW_TAG;
const repository = process.env.REPOSITORY;

const { data } = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: newTag,
});

const dockerInfo = `

---
As with all our previous releases, you can find the Docker images:
- [Backend](https://ghcr.io/${repository}/backend:${newTag})
- [Ingester](https://ghcr.io/${repository}/ingester:${newTag})


${data.body}`;

await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: newTag,
name: data.name,
body: dockerInfo,
draft: true,
prerelease: false,
});
};
7 changes: 7 additions & 0 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Build and push docker images

on:
workflow_call:
inputs:
release-tag:
description: Release tag to add to images
required: false
type: string
default: ''
workflow_dispatch:

permissions:
Expand Down Expand Up @@ -42,6 +48,7 @@ jobs:
type=ref,event=branch
type=sha,format=short
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=${{ inputs.release-tag }},enable=${{ inputs.release-tag != '' }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Release Cairo Coder

on:
workflow_dispatch:
inputs:
release-type:
description: Type of release
required: true
type: choice
options:
- patch
- minor
- major
default: minor

permissions:
contents: write
packages: write

jobs:
update-version:
runs-on: ubuntu-latest
outputs:
new-version: ${{ steps.version.outputs.new-version }}
new-tag: ${{ steps.version.outputs.new-tag }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Update version and create tag
id: version
run: |
npm version ${{ inputs.release-type }} --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")

echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "new-tag=v$NEW_VERSION" >> $GITHUB_OUTPUT

echo "NEW_VERSION=$NEW_VERSION"
echo "NEW_TAG=v$NEW_VERSION"

git config --local user.email "${{ github.actor }}@users.noreply.github.com"
git config --local user.name "${{ github.actor }}"

git add package.json
git commit -m "release: v$NEW_VERSION"
git tag "v$NEW_VERSION"
git push origin HEAD --tags

build-new-image:
needs: update-version
uses: ./.github/workflows/publish-image.yml
with:
release-tag: ${{ needs.update-version.outputs.new-tag }}
secrets: inherit

create-release:
needs: [update-version, build-new-image]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create draft release
uses: actions/github-script@v7
with:
script: |
const script = require('./.github/scripts/create-release.js');
await script({ github, context });
env:
NEW_TAG: ${{ needs.update-version.outputs.new-tag }}
REPOSITORY: ${{ github.repository }}
1 change: 0 additions & 1 deletion .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ runtimes:
lint:
enabled:
- actionlint@1.7.7
- checkov@3.2.439
- git-diff-check
- hadolint@2.12.1-beta
- markdownlint@0.45.0
Expand Down