Skip to content
Draft
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
110 changes: 92 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,102 @@
name: Dafda CI Release
name: Dafda Release

on:
push:
branches:
- master
tags:
- "*.*.*"
workflow_dispatch:
inputs:
version:
description: Release version (e.g. 1.2.3)
required: true
type: string
dry_run:
description: Dry run (build/test/pack only, no push/publish)
required: false
default: false
type: boolean

permissions:
contents: write

jobs:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion: I noticed the commit/tag/push currently happens before the build & test. So if the tests fail, we’ve already pushed a release: x.y.z commit and tag to the branch, but nothing has actually been published to NuGet. I’d suggest slightly changing the order:

  1. Update src/Dafda/Dafda.csproj version
  2. Build → Test → Pack
  3. Commit + tag + git push --follow-tags
  4. NuGet push + GitHub Release

That way, we only push the tag once we have a green build. 🙂

build:
name: Build NuGet package
release:
name: Build and publish release
runs-on: ubuntu-latest
env:
VERSION: ${{ github.event.inputs.version }}
DRY_RUN: ${{ inputs.dry_run }}

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build package
run: make package CONFIGURATION=Release
- name: Push package
if: startsWith(github.ref, 'refs/tags/')

- name: Validate release version
run: |
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z\.-]+)?$ ]]; then
echo "Invalid version format: $VERSION"
exit 1
fi

- name: Ensure tag does not already exist
run: |
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION already exists"
exit 1
fi

- name: Update project version
run: sed -i -E "s#<Version>.*</Version>#<Version>${VERSION}</Version>#" src/Dafda/Dafda.csproj

- name: Commit version and create tag
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
GIT_USER_NAME: ${{ github.actor }}
GIT_USER_EMAIL: ${{ github.actor }}@users.noreply.github.com
run: |
echo "Pushing new release with version ${GITHUB_REF:10}..."
make push CONFIGURATION=Release
git config user.name "$GIT_USER_NAME"
git config user.email "$GIT_USER_EMAIL"

if git diff --quiet -- src/Dafda/Dafda.csproj; then
echo "Version is already set to $VERSION"
else
git add src/Dafda/Dafda.csproj
git commit -m "release: $VERSION"
fi

git tag "$VERSION"

if [ "$DRY_RUN" = "true" ]; then
echo "Dry run enabled: skipping git push"
else
git push origin "HEAD:${GITHUB_REF_NAME}" --follow-tags
fi

- name: Restore dependencies
run: dotnet restore src/Dafda.sln

- name: Build
run: dotnet build --configuration Release --no-restore src/Dafda.sln

- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal src/Dafda.sln

- name: Pack NuGet package
run: dotnet pack src/Dafda/Dafda.csproj --configuration Release --no-build --output .output

- name: Push package to NuGet
if: ${{ !inputs.dry_run }}
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ".output/Dafda.$VERSION.nupkg" --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY"

- name: Create GitHub Release
if: ${{ !inputs.dry_run }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
generate_release_notes: true
files: .output/Dafda.${{ env.VERSION }}.nupkg
85 changes: 0 additions & 85 deletions Makefile

This file was deleted.

33 changes: 13 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,23 @@ See [dfds.github.io/dafda](https://dfds.github.io/dafda/) for more the documenta

## Building and Releasing

Dafda is build and released using a combination of `make` and [GitHub Actions](https://github.com/dfds/dafda/blob/master/.github/workflows/release.yml)
Dafda is built and released using [GitHub Actions](https://github.com/dfds/dafda/blob/master/.github/workflows/release.yml)

You will need the dotnet sdk. Refer to the [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu) on how to install
You will need the dotnet sdk for local development. Refer to the [Microsoft Documentation](https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu) on how to install.

Dafda is available on [NuGet](https://www.nuget.org/packages/Dafda/).

### Versioning
### Releases

Run:
Releases are created from the **Dafda Release** workflow in GitHub Actions.

```bash
make version
```

And input the new version of Dafda. This will update the `Dafda.csproj` with the new version.

### NuGet Packages
1. Open **Actions** in GitHub.
2. Run **Dafda Release**.
3. Enter the version to release (for example `1.2.3`).

Run:

```bash
make release
git push --follow-tags
```
The workflow will update `src/Dafda/Dafda.csproj`, create and push a tag, build/test/pack, publish to NuGet, and create a GitHub release.

Will git tag with the current version (see [Versioning](#versioning), and GitHub Actions will take care of building, and pushing to NuGet.
> Note: The repository must define a `NUGET_API_KEY` secret for publishing to nuget.org.

### Documentation

Expand All @@ -42,15 +33,17 @@ Documentation is written in markdown, and compiled to a static site using [MkDoc
#### Development

```bash
make docs-dev
cd docs
docker-compose up -d
```

Uses `docker-compose` to run `MkDocs` development server, which watches changes to `/docs` folder. The website is available on [`http://localhost:8000`](`http://localhost:8000`).

#### Release

```bash
make docs-deploy
cd docs
docker-compose run --rm mkdocs-deploy
```

Will build and deploy the static site to GitHub Pages.
11 changes: 0 additions & 11 deletions azure-piplines.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ docker run --rm -it -v ${PWD}:/docs squidfunk/mkdocs-material build
### Deploy documentation to GitHub Pages

```bash
docker run --rm -it -v ~/.ssh:/root/.ssh -v ${PWD}:/docs squidfunk/mkdocs-material gh-deploy
docker-compose run --rm mkdocs-deploy
```
8 changes: 8 additions & 0 deletions docs/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ services:
- 8000:8000
volumes:
- ${PWD}:/docs

mkdocs-deploy:
image: squidfunk/mkdocs-material:4.1.2
entrypoint: ["mkdocs"]
command: ["gh-deploy", "--clean", "--config-file", "mkdocs.yml"]
volumes:
- ${PWD}:/docs
- ~/.ssh:/root/.ssh
2 changes: 1 addition & 1 deletion tester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ First create a local nuget package with your changes. Update the nuget reference
Run:

```bash
make package
dotnet pack src/Dafda/Dafda.csproj --configuration Release --output .output
```

To start a local Kafka instance, run:
Expand Down
Loading