Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
name: Semantic Release

on:
push:
branches:
- main

jobs:
semantic-release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
outputs:
next-version: ${{ steps.semantic-release.outputs.next-version }}

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

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"

- name: Install Semantic Release
run: >
npm install
semantic-release
conventional-changelog-conventionalcommits
@semantic-release/changelog
@semantic-release/exec
@semantic-release/git
semantic-release-major-tag

- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures

- name: Run Semantic Release
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release
VERSION=$(cat VERSION)
echo "Next version: $VERSION"
echo "next-version=$VERSION" >> $GITHUB_OUTPUT

docker:
runs-on: ubuntu-latest
needs: semantic-release
if: ${{ needs.semantic-release.outputs.next-version }}
permissions:
packages: write # required to push to GHCR
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
run: |
IMAGE_NAME="ghcr.io/${{ github.repository_owner }}/cpp-cli"
V_TAG="${IMAGE_NAME}:v${{ needs.semantic-release.outputs.next-version }}"
LATEST_TAG="${IMAGE_NAME}:latest"

echo "Building image $V_TAG and $LATEST_TAG"
docker build -t "$V_TAG" -t "$LATEST_TAG" .

- name: Push Docker image
run: |
IMAGE_NAME="ghcr.io/${{ github.repository_owner }}/cpp-cli"
docker push "${IMAGE_NAME}:v${{ needs.semantic-release.outputs.next-version }}"
docker push "${IMAGE_NAME}:latest"
45 changes: 0 additions & 45 deletions .github/workflows/semantic-release.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ plugins:
- assets:
- CHANGELOG.md
- semantic-release-major-tag
- - "@semantic-release/exec"
- prepareCmd: "echo ${nextRelease.version} > VERSION"
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ubuntu:22.04 AS builder

RUN apt update && apt install -y build-essential cmake

WORKDIR /app

COPY CMakeLists.txt ./
COPY src ./src
COPY tests ./tests

RUN mkdir build && cd build && \
cmake .. && \
make

FROM ubuntu:22.04

WORKDIR /app

COPY --from=builder /app/build/cpp-cli /usr/local/bin/cpp-cli

ENTRYPOINT ["cpp-cli"]
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Hello world C++ CLI application.

## Features

- [CI](.github/workflows/ci.yaml)
- [Semantic Release](.github/workflows/semantic-release.yaml) on merge to the `main` branch
- [CI](.github/workflows/ci.yaml) on PR or merge to the `main` branch
- [Release](.github/workflows/release.yaml) on merge to the `main` branch

## Development and Testing

Expand Down Expand Up @@ -44,3 +44,11 @@ Cleanup:
popd
rm -rf build/
```

## Distribution

Docker build and run:

```shell
sudo docker run --rm $(sudo docker build -q .)
```