-
Notifications
You must be signed in to change notification settings - Fork 749
CI: Add a release preparation and release workflow #1559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
c2995cf
08a9efa
f6ac162
d9d67ef
b0f8c5e
6adb765
604550e
1dde323
921b759
d980fe3
f789004
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"action": "workflow_dispatch", | ||
"inputs": { | ||
"versionBump": "minor" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,69 @@ | ||||||
#!/usr/bin/env bash | ||||||
|
||||||
# $fragment: see possible options https://github.com/christian-draeger/increment-semantic-version/tree/1.2.3?tab=readme-ov-file#version-fragment | ||||||
if [ "$fragment" = "" ]; then | ||||||
fragment=$1 | ||||||
fi | ||||||
|
||||||
allowed_crates="protocol oauth core discovery audio metadata playback connect" | ||||||
|
||||||
if [ "$fragment" = "patch" ]; then | ||||||
last_tag=$(git describe --tags --abbrev=0) | ||||||
awk_crates=$(echo "$allowed_crates" | tr ' ' '|') | ||||||
diff_crates=$(git diff $last_tag... --stat --name-only \ | ||||||
| awk '/\.(rs|proto)$/{print}' \ | ||||||
| awk "/($awk_crates)\//{print}" \ | ||||||
| cut -d '/' -f 1 \ | ||||||
| uniq \ | ||||||
| tr \\n '\ ' \ | ||||||
| xargs ) | ||||||
echo "upgrading the following crates: [$diff_crates]" | ||||||
else | ||||||
diff_crates=$allowed_crates | ||||||
echo "upgrading all crates for consistency" | ||||||
fi | ||||||
|
||||||
# append bin so that the version of the binary is also bumped | ||||||
diff_crates="$diff_crates bin" | ||||||
|
||||||
# required by script as it's usually a github action | ||||||
export GITHUB_OUTPUT="version.txt" | ||||||
# https://github.com/christian-draeger/increment-semantic-version/tree/1.2.3 | ||||||
increment_semver=$(curl https://raw.githubusercontent.com/christian-draeger/increment-semantic-version/refs/tags/1.2.3/entrypoint.sh) | ||||||
|
||||||
for diff_crate in $diff_crates ; do | ||||||
if [ "$diff_crate" = "bin" ]; then | ||||||
toml="./Cargo.toml" | ||||||
else | ||||||
toml="./$diff_crate/Cargo.toml" | ||||||
fi | ||||||
|
||||||
from="$(cat $toml | awk "/version/{print; exit}" | cut -d\" -f 2)" | ||||||
|
||||||
# execute script inline, extract result and remove output file | ||||||
echo "$increment_semver" | bash /dev/stdin $from $fragment | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Executing downloaded script content through bash poses a security risk. The script content should be verified or the functionality should be implemented locally. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
to=$(cat $GITHUB_OUTPUT | cut -d= -f 2) | ||||||
rm $GITHUB_OUTPUT | ||||||
|
||||||
echo "upgrading [librespot-$diff_crate] from [$from] to [$to]" | ||||||
|
||||||
# replace version in associated diff_crate toml | ||||||
sed -i "0,/$from/{s/$from/$to/}" $toml | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sed command may incorrectly replace version numbers that appear elsewhere in the file. It should be more specific to target only the version field, e.g.,
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
|
||||||
if [ "$diff_crate" = "bin" ]; then | ||||||
continue | ||||||
fi | ||||||
|
||||||
# update workspace dependency in root toml | ||||||
sed -i "/librespot-$diff_crate/{s/$from/$to/}" ./Cargo.toml | ||||||
|
||||||
# update related dependencies in diff_crate | ||||||
for allowed_crate in $allowed_crates ; do | ||||||
cat ./$allowed_crate/Cargo.toml | grep librespot-$diff_crate > /dev/null | ||||||
if [ $? = 0 ]; then | ||||||
sed -i "/librespot-$diff_crate/{s/$from/$to/}" ./$allowed_crate/Cargo.toml | ||||||
fi | ||||||
done | ||||||
done | ||||||
|
||||||
exit 0 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,57 @@ | ||||||
--- | ||||||
# test with | ||||||
# act --job prepare-release --eventpath ./.github/example/prepare-release.event | ||||||
name: prepare release | ||||||
on: | ||||||
workflow_dispatch: | ||||||
inputs: | ||||||
versionBump: | ||||||
description: "Version bump for" | ||||||
required: true | ||||||
type: choice | ||||||
options: | ||||||
- major | ||||||
- minor | ||||||
- patch | ||||||
|
||||||
jobs: | ||||||
prepare-release: | ||||||
name: Prepare release | ||||||
runs-on: ubuntu-latest | ||||||
permissions: | ||||||
contents: write | ||||||
steps: | ||||||
- name: Checkout code | ||||||
uses: actions/checkout@v5 | ||||||
with: | ||||||
fetch-tags: true | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The parameter should be
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
|
||||||
- name: Install Rust toolchain | ||||||
uses: dtolnay/rust-toolchain@stable | ||||||
|
||||||
- name: Bump versions | ||||||
env: | ||||||
fragment: ${{ github.event.inputs.versionBump }} | ||||||
run: ./.github/scripts/bump-versions.sh | ||||||
|
||||||
- name: Update Cargo.lock | ||||||
run: cargo update --workspace | ||||||
|
||||||
- name: Get binary version | ||||||
id: get-version | ||||||
run: | | ||||||
VERSION=$(cat ./Cargo.toml | awk "/version/{print; exit}" | cut -d\" -f 2) | ||||||
echo VERSION=$VERSION >> ${GITHUB_OUTPUT} | ||||||
|
||||||
- name: Update Changelog | ||||||
uses: thomaseizinger/[email protected] | ||||||
with: | ||||||
tag: v${{ steps.get-version.outputs.VERSION }} | ||||||
version: ${{ steps.get-version.outputs.VERSION }} | ||||||
|
||||||
- name: Commit version prepare | ||||||
uses: stefanzweifel/git-auto-commit-action@v6 | ||||||
if: ${{ !env.ACT }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we check more generally for development environments besides ACT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And how would that look like? Or what different development environment do you have in mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah don't know how we can make that work with GitHub actions? Not an expert. But if we would have something like: if: ${{ env.PRODUCTION }} then that could be more robust. Can we set that environment variable somehow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah good point restricting it from the other side. I will take a look if there is something github provides. Even tho I think this will break the intention of not running this step locally when using act, but I will report about that when I looked into it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I tried to find something similar that is supported by github out of the box, but I couldn't find anything. So only disabling it when using act seems good enough from my perspective. |
||||||
with: | ||||||
commit_message: 'Prepare for v${{ steps.get-version.outputs.VERSION }} release' | ||||||
file_pattern: '*.md *.toml *.lock' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: release.yml | ||
on: | ||
release: | ||
types: | ||
- created | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish-crates: | ||
name: Publish librespot | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v5 | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Cache Rust dependencies | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install dependencies | ||
run: sudo apt-get update && sudo apt-get install -y libasound2-dev | ||
|
||
- name: Verify librespot workspace | ||
run: cargo publish --workspace --dry-run | ||
|
||
- name: Publish librespot workspace | ||
if: ${{ !env.ACT }} | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
run: cargo publish --workspace --no-verify |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "librespot-audio" | ||
version.workspace = true | ||
version = "0.7.1" | ||
rust-version.workspace = true | ||
authors = ["Paul Lietar <[email protected]>"] | ||
license.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "librespot-connect" | ||
version.workspace = true | ||
version = "0.7.1" | ||
rust-version.workspace = true | ||
authors = ["Paul Lietar <[email protected]>"] | ||
license.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "librespot-core" | ||
version.workspace = true | ||
version = "0.7.1" | ||
rust-version.workspace = true | ||
authors = ["Paul Lietar <[email protected]>"] | ||
license.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "librespot-discovery" | ||
version.workspace = true | ||
version = "0.7.1" | ||
rust-version.workspace = true | ||
authors = ["Paul Lietar <[email protected]>"] | ||
license.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "librespot-metadata" | ||
version.workspace = true | ||
version = "0.7.1" | ||
rust-version.workspace = true | ||
authors = ["Paul Lietar <[email protected]>"] | ||
license.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "librespot-oauth" | ||
version.workspace = true | ||
version = "0.7.1" | ||
rust-version.workspace = true | ||
authors = ["Nick Steel <[email protected]>"] | ||
license.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "librespot-playback" | ||
version.workspace = true | ||
version = "0.7.1" | ||
rust-version.workspace = true | ||
authors = ["Sasha Hilton <[email protected]>"] | ||
license.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "librespot-protocol" | ||
version.workspace = true | ||
version = "0.7.1" | ||
rust-version.workspace = true | ||
authors = ["Paul Liétar <[email protected]>"] | ||
license.workspace = true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downloading and executing arbitrary scripts from the internet without verification poses a security risk. Consider vendoring this script or using a verified GitHub Action instead.
Copilot uses AI. Check for mistakes.