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
76 changes: 76 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Publish to crates.io

on:
push:
tags: ['v*']

jobs:
test:
runs-on: ubuntu-24.04

steps:
- name: Print environment (debug)
run: env

- name: Fetch sources
uses: actions/checkout@v4
with:
submodules: recursive

- name: Run tests
uses: frequenz-floss/[email protected]

create-github-release:
needs: ["test"]
name: Create GitHub release
runs-on: ubuntu-24.04
permissions:
# We need write permissions on contents to create GitHub releases and on
# discussions to create the release announcement in the discussion forums
contents: write
discussions: write
steps:
- name: Download RELEASE_NOTES.md
run: |
set -ux
gh api \
-X GET \
-f ref=$REF \
-H "Accept: application/vnd.github.raw" \
"/repos/$REPOSITORY/contents/RELEASE_NOTES.md" \
> RELEASE_NOTES.md
env:
REF: ${{ github.ref }}
REPOSITORY: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub release
run: |
set -ux
extra_opts=
if echo "$REF_NAME" | grep -- -; then extra_opts=" --prerelease"; fi
gh release create \
-R "$REPOSITORY" \
--notes-file RELEASE_NOTES.md \
--generate-notes \
$extra_opts \
$REF_NAME \
dist/*
env:
REF_NAME: ${{ github.ref_name }}
REPOSITORY: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
needs: ["create-github-release"]
runs-on: ubuntu-24.04
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v5
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing to Frequenz Microgrid Component Graph

## Releasing

These are the steps to create a new release:

1. Get the latest head you want to create a release from.

2. Update the `RELEASE_NOTES.md` file if it is not complete, up to date, and
remove template comments (`<!-- ... ->`) and empty sections. Submit a pull
request if an update is needed, wait until it is merged, and update the
latest head you want to create a release from to get the new merged pull
request.

3. Create a new signed tag using the release notes and
a [semver](https://semver.org/) compatible version number with a `v` prefix,
for example:

```sh
git tag -s --cleanup=whitespace -F RELEASE_NOTES.md v0.0.1
```

4. Push the new tag.

5. A GitHub action will test the tag and if all goes well it will create
a [GitHub
Release](https://github.com/frequenz-floss/frequenz-microgrid-component-graph-rs/releases),
and upload a new package to
[crates.io](https://crates.io/crates/frequenz-microgrid-component-graph)
automatically.

6. Once this is done, reset the `RELEASE_NOTES.md` with the template:

```sh
cp .github/RELEASE_NOTES.template.md RELEASE_NOTES.md
```

Commit the new release notes and create a PR (this step should be automated
eventually too).

7. Celebrate!
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Frequenz Microgrid Component Graph

![Crates.io Version](https://img.shields.io/crates/v/frequenz-microgrid-component-graph) ![docs.rs](https://img.shields.io/docsrs/frequenz-microgrid-component-graph)

This is a library for representing the components of a microgrid and the
connections between them as a Directed Acyclic Graph (DAG).

Expand Down