Skip to content
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

Trigger GitHub release/publish explicitly, scripts cleanup #682

Merged
merged 4 commits into from
Jan 21, 2025

Conversation

PetrGlad
Copy link
Collaborator

This avoid irrelevant errors during build as release/publish is now triggered manually. This helps to make it intentional, now it is not obvious that change in Cargo.toml may trigger publication, so some versions may end up on Crates.io accidentally and then be depended upon.
The tag is created only after successful publication, so we know which version was released.
Also some scripts were unnecessarily complex, I tried to streamline that.

One drawback is that one have to wait for tests on master to complete successfully. It is possible to invoke the tests from the release workflow. This is more reliable, but will do some work twice.

ref: ${{ inputs.version_tag }}

- name: Fetch tags
run: git fetch --prune --unshallow --tags
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Default checkout is shallow last-version-only. This also fetches all the tags. Previous version tried to clone the whole repo every time.

- name: Publish and tag
run: |
echo "Current git commit is $(git rev-list -n 1 HEAD)."
VERSION="$(yq '.package.version' Cargo.toml)"
Copy link
Collaborator Author

@PetrGlad PetrGlad Jan 19, 2025

Choose a reason for hiding this comment

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

yq is installed by default in GitHub's Ubuntu. Unfortunately it cannot write TOML yet. If it could we could also automatically update the cargo version to something likemajor.minor.(patch+1)-dev.

Copy link
Collaborator

Choose a reason for hiding this comment

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

lots cleaner then the grep | cut etc hack we had here, nice!

# The bot name and email is taken from here https://github.com/actions/checkout/pull/1707
# see also https://api.github.com/users/github-actions%5Bbot%5D
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
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 seems to be the actual GitHub user that executes these scripts, and it is recommended in the checkout action documentation.

@@ -0,0 +1,40 @@
name: Publish

on: workflow_dispatch
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 makes this workflow available for manual triggering on the project's Action tab.

Copy link
Collaborator

Choose a reason for hiding this comment

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

good call, we do not release that often so making it a conscious choice seems the right thing to do

@@ -28,14 +28,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: install linux deps
run: |
sudo apt update
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The action's Ubuntu image comes with the package list already. No need to update unless we need a package that was first published several days ago.

if: contains(matrix.os, 'ubuntu')

- name: install ${{ matrix.toolchain }} toolchain
id: install_toolchain
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ids are only needed to refer to this step somewhere else, no need in that right now.

echo "Tag $version_name does not exist"
echo "tag_exists=false" >> $GITHUB_OUTPUT
fi
- name: Create and push tag
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Splitting these steps into separate runs, in turn required to pass things between them, which is too complex.
Also sh/bash convention is to use uppercase for variable names.
(If really necessary .inputs and .outputs seems to be the way to do it).

Copy link
Collaborator

@dvdsk dvdsk Jan 19, 2025

Choose a reason for hiding this comment

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

it is such pain to pass things between steps..... Honestly for my other projects the github CI just calls a bash file (thats all it does). Bash is just as cursed as these workflows but at least I know bash and I can test it locally.

Copy link
Collaborator

@dvdsk dvdsk left a comment

Choose a reason for hiding this comment

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

Thanks for going through the pain of fixing this. Lets hope it works :)

Good to merge (go ahead (assuming our done).

@PetrGlad
Copy link
Collaborator Author

Will try to merge another day, when I have time to debug it. Chances are this won't work on the first try.

@dvdsk
Copy link
Collaborator

dvdsk commented Jan 21, 2025

Will try to merge another day, when I have time to debug it. Chances are this won't work on the first try.

if it does not, just so you know, its not a problem. Worst case we revert the merge when we want to release again (which will be in many weeks anyway)

@PetrGlad PetrGlad merged commit d93b1f3 into RustAudio:master Jan 21, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants