Skip to content

CI: tags releases #589

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

Merged
merged 1 commit into from
Jul 5, 2024
Merged

CI: tags releases #589

merged 1 commit into from
Jul 5, 2024

Conversation

romainpi
Copy link
Contributor

@romainpi romainpi commented Jul 4, 2024

This PR is a solution to issue #587.

This PR contains two new jobs in .github/workflows/ci.yml:

  • An ephemeral job create-tags-for-past-releases that will create and push tags for previous releases of Rodio.
  • A new job create-git-tag that will detect when the version field in the [package] section of the ./Cargo.toml file is modified on the master branch, create a tag and push it.

The ephemeral job create-tags-for-past-releases contains a JSON array storing release version numbers and their corresponding git commit hash. Using jq it loops through the JSON array and tags the commits and then finally pushes the tags.

I have tested these changes and they are working correctly on the self-hosted workers.

The next step will be to remove the ephemeral job create-tags-for-past-releases from .github/workflows/ci.yml.

Important !!!

For some reason, Github is not letting the script push some tags with the following error message:
! [remote rejected] v0.17.3 -> v0.17.3 (refusing to allow a GitHub App to create or update workflow `.github/workflows/ci.yml` without `workflows` permission)
It's a little puzzling since the action is not touching the .github/workflows/ci.yml. The only clue is the error first occurs with the tag v0.13.1 which is when the CI was migrated from Travis to Github actions.

In order to have this work, one of the maintainers needs to create a Personal Access Token with workflow rights, they will need to:

  1. Go to the PAT creation page here: https://github.com/settings/tokens/new
  2. Tick the workflow checkbox, save and copy the token to clipboard.
  3. Go to https://github.com/RustAudio/rodio/settings/secrets/actions/new and create a secret with the name WORKFLOW_TOKEN and paste the token that should be in the clipboard.

I would recommend setting the expiration date of the token to "No expiration" since the token will only be put into Github secrets. The script will check for the existence of this token and will fail if not set.

Notes

For the Rodio project the logic that defines a new release version is as follow:

When the version is incremented in the Cargo.toml CI triggers a release to crates.io

Looking at the .github/workflows/ci.yml file where the logic is implemented we can see that the cargo-publish job runs for all commits that are pushed to the master branch. The job will try to publish to the crates.io registry; it should succeed when trying to publish with a new version number and it should fail when trying to publish with a version number that was already present on the crates.io registry.

Here comes a long useless explanation. TLDR: I thought I could parse the git history, realized I couldn't then cheated by doing it manually.

At first I tried building a bash script that would go through the commit history detecting changes to the version field in the [package] section of the ./Cargo.toml file and tag those with the value in the version field. That worked with some of the releases (the ones that had been pushed directly to the master branch) but failed by flagging commits that were parts of a PR merge; these new versions would only be published to the registry when the PR was merged to the master branch, and sometimes the PR branches contained posterior changes to the code so tagging those commits where the version changed was sometimes incorrect - even in the case that the commit changing the version was the last commit in the PR the tag would point to the correct codebase corresponding to that release but not the actual commit and that would be inaceptable ;).

I then tried many different techniques such as having the bash script go through all the descending commits of these version changing commits and try to detect PR merge commits with git log --reverse --merges --ancestry-path <hash>..HEAD (and other commands) and reading the commit subject looking for "Merge pull request #". I will spare you the details but it got messy and I'm starting to forget the myriad of problems I ran into - for a little while it looked like I was making progress but I got issues with merges rebasing master to a PR branch, I did things like counting the number of children and parents commits and making assumptions. The bash script was starting to grow in size, it didn't look good. In the end I had something that would sometimes mislabel release commits that had been pushed directly to the master branch, would sometimes tag the same commit with multiple versions, etc.

The 0.0.1 release was impossible to detect since this was the starting value there was no way of discerning which commit had triggered the publish, and the subsequent commits working on 0.0.2 were not easily detectable. That's when I thought of scraping the data off of https://crates.io/api/v1/crates/rodio which doesn't include commit hashes but has a created_at value. I thought I could perhaps compare datetimes of the published versions with commits but it wasn't the solution - firstly nothing guarantees that the commiter's machine date can be wrongly set; we can't tell how much time the commiter waited to push his commits to github; we don't know how long it takes the workers to start working, etc. But at least we had an idea of the day that the release was published.

In the end I gave up on the bash script that tries to detect version commits. It started to be too much code and since it's ideally meant to be run once there was no reason to keep going down that route. I' sure a git savant might be able to solve this with 3 lines of code. Anyways, with all the almost-correct info I had generated and scraping https://crates.io/api/v1/crates/rodio to get the versions and created_at values, I ended up manually identifying and confirming some releases. Nevermind the fact I finally read the message from @est31 stating most of the commit hashes were available from https://lib.rs/crates/rodio/versions but that was already too late!

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.

Looks good!

@dvdsk
Copy link
Collaborator

dvdsk commented Jul 4, 2024

I have tested these changes and they are working correctly on the self-hosted workers.

you have clearly gone through CI hell for us 😅

Here comes a long useless explanation. TLDR: I thought I could parse the git history, realized I couldn't then cheated by doing it manually.

Was a fun read, and good to know the pain you went through for this.

In order to have this work, one of the maintainers needs to create a Personal Access Token with workflow rights, they will need to:

I'll have a good at that in a bit 👍 No idea what exactly my rights in the repo are, if I cant do it ill ensure someone who is autorized does it.

@dvdsk
Copy link
Collaborator

dvdsk commented Jul 4, 2024

@est31 I do not have access to the settings page, can you set up the workflow token?

@est31
Copy link
Member

est31 commented Jul 5, 2024

I have added a WORKFLOW_TOKEN token to the repository:

Screenshot_20240706_002530

@dvdsk
Copy link
Collaborator

dvdsk commented Jul 5, 2024

lets see if it works

@dvdsk dvdsk merged commit 4f21557 into RustAudio:master Jul 5, 2024
12 checks passed
@dvdsk
Copy link
Collaborator

dvdsk commented Jul 5, 2024

nope :(

logs give me:

remote: Permission to RustAudio/rodio.git denied to est31.
fatal: unable to access 'https://github.com/RustAudio/rodio/': The requested URL returned error: 403
Error: Process completed with exit code 128.

it seems to fail on:

  git push origin --tags

any idea @romainpi ?

no rush btw, I'm about to go to sleep anyways, have a good night all! 🌙

@romainpi
Copy link
Contributor Author

romainpi commented Jul 5, 2024

any idea @romainpi ?

no rush btw, I'm about to go to sleep anyways, have a good night all! 🌙

Hmm yes I have a few ideas as to why it might be failing. I'm on mobile now with no access to my computer but I'll be able to look into it within 18 hours. Also I'm not able to see the details of the failing job (access rights perhaps?) . Could I ask for a full log of the create-tags-for-past-releases job please? thanks

@dvdsk
Copy link
Collaborator

dvdsk commented Jul 6, 2024

The raw log:

its pretty large

2024-07-05T23:26:03.4752184Z Current runner version: '2.317.0'
2024-07-05T23:26:03.4775439Z ##[group]Operating System
2024-07-05T23:26:03.4776206Z Ubuntu
2024-07-05T23:26:03.4776525Z 22.04.4
2024-07-05T23:26:03.4776846Z LTS
2024-07-05T23:26:03.4777294Z ##[endgroup]
2024-07-05T23:26:03.4777638Z ##[group]Runner Image
2024-07-05T23:26:03.4778063Z Image: ubuntu-22.04
2024-07-05T23:26:03.4778530Z Version: 20240630.1.0
2024-07-05T23:26:03.4779509Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20240630.1/images/ubuntu/Ubuntu2204-Readme.md
2024-07-05T23:26:03.4780915Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20240630.1
2024-07-05T23:26:03.4781829Z ##[endgroup]
2024-07-05T23:26:03.4782221Z ##[group]Runner Image Provisioner
2024-07-05T23:26:03.4782711Z 2.0.370.1
2024-07-05T23:26:03.4783073Z ##[endgroup]
2024-07-05T23:26:03.4785362Z ##[group]GITHUB_TOKEN Permissions
2024-07-05T23:26:03.4787093Z Actions: write
2024-07-05T23:26:03.4787691Z Attestations: write
2024-07-05T23:26:03.4788269Z Checks: write
2024-07-05T23:26:03.4788657Z Contents: write
2024-07-05T23:26:03.4789007Z Deployments: write
2024-07-05T23:26:03.4789474Z Discussions: write
2024-07-05T23:26:03.4789868Z Issues: write
2024-07-05T23:26:03.4790187Z Metadata: read
2024-07-05T23:26:03.4790628Z Packages: write
2024-07-05T23:26:03.4791010Z Pages: write
2024-07-05T23:26:03.4791384Z PullRequests: write
2024-07-05T23:26:03.4791826Z RepositoryProjects: write
2024-07-05T23:26:03.4792286Z SecurityEvents: write
2024-07-05T23:26:03.4792688Z Statuses: write
2024-07-05T23:26:03.4793102Z ##[endgroup]
2024-07-05T23:26:03.4796451Z Secret source: Actions
2024-07-05T23:26:03.4797133Z Prepare workflow directory
2024-07-05T23:26:03.5524365Z Prepare all required actions
2024-07-05T23:26:03.5679566Z Getting action download info
2024-07-05T23:26:03.6685661Z Download action repository 'actions/checkout@v4' (SHA:692973e3d937129bcbf40652eb9f2f61becf3332)
2024-07-05T23:26:04.0728806Z Complete job name: create-git-tag
2024-07-05T23:26:04.1868735Z ##[group]Run if [ -z "" ]; then
2024-07-05T23:26:04.1870191Z �[36;1mif [ -z "
" ]; then�[0m
2024-07-05T23:26:04.1870884Z �[36;1m echo "Personal access token WORKFLOW_TOKEN is not set"�[0m
2024-07-05T23:26:04.1871683Z �[36;1m exit 1�[0m
2024-07-05T23:26:04.1872078Z �[36;1melse�[0m
2024-07-05T23:26:04.1872525Z �[36;1m echo "Checked WORKFLOW_TOKEN is set"�[0m
2024-07-05T23:26:04.1873192Z �[36;1mfi�[0m
2024-07-05T23:26:04.1988855Z shell: /usr/bin/bash -e {0}
2024-07-05T23:26:04.1989393Z env:
2024-07-05T23:26:04.1989794Z RUSTFLAGS: -C debuginfo=0 -D warnings
2024-07-05T23:26:04.1990410Z CARGO_TERM_COLOR: always
2024-07-05T23:26:04.1990881Z CARGO_INCREMENTAL: 0
2024-07-05T23:26:04.1991317Z ##[endgroup]
2024-07-05T23:26:04.2227619Z /home/runner/work/_temp/641d7085-b30e-443f-9b8b-8b4355aa5a47.sh: line 5: WORKFLOW_TOKEN: command not found
2024-07-05T23:26:04.2228700Z Checked is set
2024-07-05T23:26:04.2484300Z ##[group]Run actions/checkout@v4
2024-07-05T23:26:04.2484898Z with:
2024-07-05T23:26:04.2485834Z token: ***
2024-07-05T23:26:04.2486381Z repository: RustAudio/rodio
2024-07-05T23:26:04.2486871Z ssh-strict: true
2024-07-05T23:26:04.2487292Z ssh-user: git
2024-07-05T23:26:04.2487741Z persist-credentials: true
2024-07-05T23:26:04.2488208Z clean: true
2024-07-05T23:26:04.2488625Z sparse-checkout-cone-mode: true
2024-07-05T23:26:04.2489203Z fetch-depth: 1
2024-07-05T23:26:04.2489558Z fetch-tags: false
2024-07-05T23:26:04.2489977Z show-progress: true
2024-07-05T23:26:04.2490442Z lfs: false
2024-07-05T23:26:04.2490772Z submodules: false
2024-07-05T23:26:04.2491198Z set-safe-directory: true
2024-07-05T23:26:04.2491700Z env:
2024-07-05T23:26:04.2492085Z RUSTFLAGS: -C debuginfo=0 -D warnings
2024-07-05T23:26:04.2492592Z CARGO_TERM_COLOR: always
2024-07-05T23:26:04.2493110Z CARGO_INCREMENTAL: 0
2024-07-05T23:26:04.2493535Z ##[endgroup]
2024-07-05T23:26:04.4521179Z Syncing repository: RustAudio/rodio
2024-07-05T23:26:04.4523447Z ##[group]Getting Git version info
2024-07-05T23:26:04.4524971Z Working directory is '/home/runner/work/rodio/rodio'
2024-07-05T23:26:04.4526308Z [command]/usr/bin/git version
2024-07-05T23:26:04.4547490Z git version 2.45.2
2024-07-05T23:26:04.4585937Z ##[endgroup]
2024-07-05T23:26:04.4612776Z Temporarily overriding HOME='/home/runner/work/_temp/6c9466d0-0670-4d4b-aecf-e46344602797' before making global git config changes
2024-07-05T23:26:04.4616577Z Adding repository directory to the temporary git global config as a safe directory
2024-07-05T23:26:04.4618787Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/rodio/rodio
2024-07-05T23:26:04.4651514Z Deleting the contents of '/home/runner/work/rodio/rodio'
2024-07-05T23:26:04.4655129Z ##[group]Initializing the repository
2024-07-05T23:26:04.4659067Z [command]/usr/bin/git init /home/runner/work/rodio/rodio
2024-07-05T23:26:04.4751349Z hint: Using 'master' as the name for the initial branch. This default branch name
2024-07-05T23:26:04.4754727Z hint: is subject to change. To configure the initial branch name to use in all
2024-07-05T23:26:04.4756826Z hint: of your new repositories, which will suppress this warning, call:
2024-07-05T23:26:04.4758065Z hint:
2024-07-05T23:26:04.4760336Z hint: git config --global init.defaultBranch
2024-07-05T23:26:04.4761559Z hint:
2024-07-05T23:26:04.4762794Z hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
2024-07-05T23:26:04.4765927Z hint: 'development'. The just-created branch can be renamed via this command:
2024-07-05T23:26:04.4767188Z hint:
2024-07-05T23:26:04.4767878Z hint: git branch -m
2024-07-05T23:26:04.4769264Z Initialized empty Git repository in /home/runner/work/rodio/rodio/.git/
2024-07-05T23:26:04.4772186Z [command]/usr/bin/git remote add origin https://github.com/RustAudio/rodio
2024-07-05T23:26:04.4803048Z ##[endgroup]
2024-07-05T23:26:04.4805640Z ##[group]Disabling automatic garbage collection
2024-07-05T23:26:04.4806935Z [command]/usr/bin/git config --local gc.auto 0
2024-07-05T23:26:04.4838445Z ##[endgroup]
2024-07-05T23:26:04.4839669Z ##[group]Setting up auth
2024-07-05T23:26:04.4843680Z [command]/usr/bin/git config --local --name-only --get-regexp core.sshCommand
2024-07-05T23:26:04.4876759Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2024-07-05T23:26:04.5227379Z [command]/usr/bin/git config --local --name-only --get-regexp http.https://github.com/.extraheader
2024-07-05T23:26:04.5265481Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2024-07-05T23:26:04.5519087Z [command]/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2024-07-05T23:26:04.5564821Z ##[endgroup]
2024-07-05T23:26:04.5565785Z ##[group]Fetching the repository
2024-07-05T23:26:04.5578657Z [command]/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +4f21557886c494c460b20bdae7685493b7863aa4:refs/remotes/origin/master
2024-07-05T23:26:05.2735981Z From https://github.com/RustAudio/rodio
2024-07-05T23:26:05.2756204Z * [new ref] 4f21557 -> origin/master
2024-07-05T23:26:05.2766075Z ##[endgroup]
2024-07-05T23:26:05.2767394Z ##[group]Determining the checkout info
2024-07-05T23:26:05.2769892Z ##[endgroup]
2024-07-05T23:26:05.2774775Z [command]/usr/bin/git sparse-checkout disable
2024-07-05T23:26:05.2827503Z [command]/usr/bin/git config --local --unset-all extensions.worktreeConfig
2024-07-05T23:26:05.2857809Z ##[group]Checking out the ref
2024-07-05T23:26:05.2862372Z [command]/usr/bin/git checkout --progress --force -B master refs/remotes/origin/master
2024-07-05T23:26:05.3802979Z Reset branch 'master'
2024-07-05T23:26:05.3804368Z branch 'master' set up to track 'origin/master'.
2024-07-05T23:26:05.3817202Z ##[endgroup]
2024-07-05T23:26:05.3858154Z [command]/usr/bin/git log -1 --format='%H'
2024-07-05T23:26:05.3881517Z '4f21557886c494c460b20bdae7685493b7863aa4'
2024-07-05T23:26:05.4004736Z ##[group]Run version=$(awk '/[package]/,/^version/ { if ($1 == "version") { gsub(/"/, "", $3); print $3 } }' Cargo.toml)
2024-07-05T23:26:05.4005948Z �[36;1mversion=$(awk '/[package]/,/^version/ { if ($1 == "version") { gsub(/"/, "", $3); print $3 } }' Cargo.toml)�[0m
2024-07-05T23:26:05.4006711Z �[36;1mecho "Version value found: $version"�[0m
2024-07-05T23:26:05.4007210Z �[36;1mecho "version=$version" >> $GITHUB_OUTPUT�[0m
2024-07-05T23:26:05.4070063Z shell: /usr/bin/bash -e {0}
2024-07-05T23:26:05.4070583Z env:
2024-07-05T23:26:05.4070926Z RUSTFLAGS: -C debuginfo=0 -D warnings
2024-07-05T23:26:05.4071379Z CARGO_TERM_COLOR: always
2024-07-05T23:26:05.4071831Z CARGO_INCREMENTAL: 0
2024-07-05T23:26:05.4072146Z ##[endgroup]
2024-07-05T23:26:05.4176758Z Version value found: 0.19.0
2024-07-05T23:26:05.4228375Z ##[group]Run version=0.19.0
2024-07-05T23:26:05.4228864Z �[36;1mversion=0.19.0�[0m
2024-07-05T23:26:05.4229249Z �[36;1mversion_name="v$version"�[0m
2024-07-05T23:26:05.4229915Z �[36;1mif git rev-parse "refs/tags/$version_name" >/dev/null 2>&1; then�[0m
2024-07-05T23:26:05.4230566Z �[36;1m echo "Tag $version_name already exists"�[0m
2024-07-05T23:26:05.4231083Z �[36;1m echo "tag_exists=true" >> $GITHUB_OUTPUT�[0m
2024-07-05T23:26:05.4231623Z �[36;1melse�[0m
2024-07-05T23:26:05.4232006Z �[36;1m echo "Tag $version_name does not exist"�[0m
2024-07-05T23:26:05.4232553Z �[36;1m echo "tag_exists=false" >> $GITHUB_OUTPUT�[0m
2024-07-05T23:26:05.4233068Z �[36;1mfi�[0m
2024-07-05T23:26:05.4289056Z shell: /usr/bin/bash -e {0}
2024-07-05T23:26:05.4289464Z env:
2024-07-05T23:26:05.4289781Z RUSTFLAGS: -C debuginfo=0 -D warnings
2024-07-05T23:26:05.4290303Z CARGO_TERM_COLOR: always
2024-07-05T23:26:05.4290696Z CARGO_INCREMENTAL: 0
2024-07-05T23:26:05.4291041Z ##[endgroup]
2024-07-05T23:26:05.4388049Z Tag v0.19.0 does not exist
2024-07-05T23:26:05.4451987Z ##[group]Run version=0.19.0
2024-07-05T23:26:05.4452476Z �[36;1mversion=0.19.0�[0m
2024-07-05T23:26:05.4452927Z �[36;1mgit config --global user.name 'github-actions'�[0m
2024-07-05T23:26:05.4453659Z �[36;1mgit config --global user.email '[email protected]'�[0m
2024-07-05T23:26:05.4454216Z �[36;1mversion_name="v$version"�[0m
2024-07-05T23:26:05.4454739Z �[36;1mgit tag -a "$version_name" -m "Release for $version_name"�[0m
2024-07-05T23:26:05.4455348Z �[36;1mgit push origin $version_name�[0m
2024-07-05T23:26:05.4511087Z shell: /usr/bin/bash -e {0}
2024-07-05T23:26:05.4511457Z env:
2024-07-05T23:26:05.4511808Z RUSTFLAGS: -C debuginfo=0 -D warnings
2024-07-05T23:26:05.4512312Z CARGO_TERM_COLOR: always
2024-07-05T23:26:05.4512683Z CARGO_INCREMENTAL: 0
2024-07-05T23:26:05.4513041Z ##[endgroup]
2024-07-05T23:26:05.5869363Z remote: Permission to RustAudio/rodio.git denied to est31.
2024-07-05T23:26:05.5871343Z fatal: unable to access 'https://github.com/RustAudio/rodio/': The requested URL returned error: 403
2024-07-05T23:26:05.5898866Z ##[error]Process completed with exit code 128.
2024-07-05T23:26:05.6001821Z Post job cleanup.
2024-07-05T23:26:05.6927318Z [command]/usr/bin/git version
2024-07-05T23:26:05.6963930Z git version 2.45.2
2024-07-05T23:26:05.7003320Z Copying '/home/runner/.gitconfig' to '/home/runner/work/_temp/30b8f5af-021c-4178-b218-090ccc94b5b2/.gitconfig'
2024-07-05T23:26:05.7014041Z Temporarily overriding HOME='/home/runner/work/_temp/30b8f5af-021c-4178-b218-090ccc94b5b2' before making global git config changes
2024-07-05T23:26:05.7015112Z Adding repository directory to the temporary git global config as a safe directory
2024-07-05T23:26:05.7018771Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/rodio/rodio
2024-07-05T23:26:05.7054484Z [command]/usr/bin/git config --local --name-only --get-regexp core.sshCommand
2024-07-05T23:26:05.7087022Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2024-07-05T23:26:05.7340331Z [command]/usr/bin/git config --local --name-only --get-regexp http.https://github.com/.extraheader
2024-07-05T23:26:05.7363340Z http.https://github.com/.extraheader
2024-07-05T23:26:05.7375821Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2024-07-05T23:26:05.7407612Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2024-07-05T23:26:05.7842437Z Cleaning up orphan processes

@romainpi
Copy link
Contributor Author

romainpi commented Jul 6, 2024

Hello, @dvdsk thanks for the log. It appear you may have sent me the logs for the create-git-tag job and not the create-tags-for-past-releases. But no matter, it turns out I was able to see the action log from my laptop, just not on mobile yesterday.

It looks like est31 may have created a "New fine-grained personal access token (beta)" not a "New personal access token (classic)" as specified in the PR description. I'm saying this because the screenshot here looks like the UI for a newly created fine-grained access token.

@est31 if you follow exactly these steps (you may not have read them as they were included deep inside my wall-of-text PR description) the workflow should hopefully work correctly.

  1. Go to the PAT (classic) creation page here: https://github.com/settings/tokens/new give it any descriptive name you want maybe something like "Token for Rodio release-tagging CI job" (I would set no expiration date for this token - please see details below)
  2. Tick the workflow checkbox, save and copy the token to clipboard.
  3. Go to https://github.com/RustAudio/rodio/settings/secrets/actions/new and create a secret with the name WORKFLOW_TOKEN and paste the token that should be in the clipboard. (the name of the secret is very important)

Once this is done, rerunning the failed jobs should work.

I'm not 100% sure if est31 added the WORKFLOW_TOKEN Github secret for the Rodio project since he didn't say he didn't explicitly announce it in this post. However the "Check if WORKFLOW_TOKEN is set" step appeared to run correctly.

If you would like me to find a solution using the new fine grained tokens I'm sure it can be made to work. Currently I'm not sure that only the "Workflow RW rights" + "Metadata read" rights (as they appear in the screenshot) are enough for it to work - it could possibly require the "Contents RW" rights for it to work. I can definitely look into it if you think the classic personal access tokens are going to be phased out by Github or if you're not comfortable having that wide personal access token exposed by a Github secrets leak.

I would recommend setting the expiration date of the token to "No expiration" since the token will only live in est31's clipboard and in the Github secrets - it's not like they are being shared between people or put in some temporary line of codes (if you trust the Github secrets...). Otherwise we may forget about the token expiring and when publishing a new release the create-git-tag will fail and then we may run into a situation where a later commit to the master branch could tag the late commit instead of the commit that published that new version on the crates.io registry.

I have tested these changes and they are working correctly on the self-hosted workers.

I made a mistake with this statement, I had of course tested on self-hosted workers on wip branch but I had also tested it with the ubuntu-latest worker on the github.com/romainpi/rodio master branch so I'm pretty confident it's working properly as the only thing changing are: the URL of the github repo, the fact that I'm owner/maintainer of that repo and the value of CRATESIO_TOKEN not being defined.

I apologize for this seemingly simple PR blowing up into something more complex than it should be.

PS: Maybe a bit ambitious but I may later suggest revamps to the Rodio CI / release process. As it stands every commit to master tries to publish itself to crates.io and the only thing preventing that is crates.io saying "Nope I've already got something published for this version". The CI should be able to detect a new version is being published without having to rely on crates.io telling it so. What if crates.io is down when pushing the commit to master?

PPS: Perhaps we could set up a beta release line on crates.io and a stable branch on Github that way the master can still be used to merge PRs and then untested PRs could be tested by more users of Rodio without having the rodio crate as a git submodule in their project. Do you know if any projects using Rodio actually test out code on master before it is published on crates.io?

Thanks!

@dvdsk
Copy link
Collaborator

dvdsk commented Jul 8, 2024

Hello, @dvdsk thanks for the log. It appear you may have sent me the logs for the create-git-tag job and not the create-tags-for-past-releases. But no matter, it turns out I was able to see the action log from my laptop, just not on mobile yesterday.

yes, since the failed for the same reason I send only one, to me the create-git-tag one seemed more important as the other one I can apply locally. Though I forgot to mention any of this to you 😅

I apologize for this seemingly simple PR blowing up into something more complex than it should be.

No worries, I put all the blame on Microsoft where it belongs (since they build a terrible CI thing, anyway back to topic).

What if crates.io is down when pushing the commit to master?

Valid those on the other hand two haven't coincided yet and if they do its not that big a deal (just wait till crates.io is back up).

Perhaps we could set up a beta release line on crates.io and a stable branch on Github

To be honest that seems like it would increase the burden on the few maintainers rodio has.

Semi off-topic:
My take on this is that new releases do not need to be that tested and that stable. If something gets through CI downstream users have the option to roll back to a previous release until a bug-fix will appear. That might bite new users however to me more relaxed contributors and maintainers are more important to the project.

@est31
Copy link
Member

est31 commented Jul 9, 2024

Currently I'm not sure that only the "Workflow RW rights" + "Metadata read" rights (as they appear in the screenshot) are enough for it to work - it could possibly require the "Contents RW" rights for it to work. I can definitely look into it if you think the classic personal access tokens are going to be phased out by Github or if you're not comfortable having that wide personal access token exposed by a Github secrets leak.

The latter please, I don't want to give this repository an access token that is valid for all repositories my account has access to.

it's not like they are being shared between people or put in some temporary line of codes (if you trust the Github secrets...).

it's not hard to extract the token once you have repository access to the rodio account. The UI limitation only keeps away the weakly determined hackers. There is a million ways to extract it, only the most obvious ones got protection from github.

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.

3 participants