Skip to content
Merged
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
75 changes: 75 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

Inconsistent checkout action versions used across the workflow. The test job uses @v4 while the publish job uses @v5. Consider standardizing on @v5 throughout for consistency.

Suggested change
uses: actions/checkout@v4
uses: actions/checkout@v5

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would rather wait for dependabot to fix.

with:
submodules: recursive

- name: Run tests
uses: frequenz-floss/gh-action-cargo-test@v1.0.0

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
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The grep command on line 51 will succeed if a hyphen appears anywhere in the tag name, not just in pre-release identifiers (e.g., 'v1.0-alpha', but also 'my-project-v1.0'). Consider using a more precise pattern like grep -E '-(alpha|beta|rc)' or checking the semantic version format more strictly.

Suggested change
if echo "$REF_NAME" | grep -- -; then extra_opts=" --prerelease"; fi
if echo "$REF_NAME" | grep -E -- '-(alpha|beta|rc)'; then extra_opts=" --prerelease"; fi

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is copied from repo-config, I'm sure it is fine.

gh release create \
-R "$REPOSITORY" \
--notes-file RELEASE_NOTES.md \
--generate-notes \
$extra_opts \
$REF_NAME
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@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1.0.3
id: auth
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}