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

Create automation script to update project version numbers across repos. #1128

Closed
johnnymatthews opened this issue Apr 28, 2022 · 10 comments · Fixed by #1169
Closed

Create automation script to update project version numbers across repos. #1128

johnnymatthews opened this issue Apr 28, 2022 · 10 comments · Fixed by #1169
Labels
dif/hard Having worked on the specific codebase is important effort/days Estimated to take multiple days, but less than a week need/analysis Needs further analysis before proceeding P2 Medium: Good to have, but can wait until someone steps up

Comments

@johnnymatthews
Copy link
Contributor

Throughout this repo we reference specific version numbers for things like Go-IPFS and IPFS Updater.

image

The problem is that where there's updates to these applications, we have to manually go through this repo and update any references. It'd be nice if we had a script that:

  1. Knew which pages to look at.
  2. Found version numbers in those pages.
  3. Checked to see if they were the latest version of the relevant apps/programs.
  4. Updates version numbers where necessary.

We can use this issue to discuss the best way of creating this script.

@johnnymatthews johnnymatthews added dif/hard Having worked on the specific codebase is important P2 Medium: Good to have, but can wait until someone steps up need/analysis Needs further analysis before proceeding effort/days Estimated to take multiple days, but less than a week labels Apr 28, 2022
@mrodriguez3313
Copy link
Contributor

Just had a question on who would run the script periodically? Would it be automated through a github action in this repo, would it be an automation on some server hosted by PL, or would someone, run the script locally and then push the changes as a pr?
The last option seems useless though as I mention it...

As I see it, (quickly glanced through the docs) the pages that would need to be altered in the case of a version update, would be those in "/ipfs-docs/docs/install" is that correct? Before talking about the script, there could be a Markdown hack that we could use to make this easier. "variables" in Markdown

So the whole process would look something like:

  1. We manually replace each version number with a variable in markdown and declare the variable at the top of the page somewhere.
  2. Script would just have to search for that variable in bash or python
  3. Check against respective repositories or dist.ipfs.io directory, either tags/releases/ or somewhere in code that defines version (ex: ipfs-update/config.go
  4. Update the one "variable" in the markdown file

This way it still keeps the portability aspect and the script does not have to go parse the whole document. The changes would be minimal to each doc site

@johnnymatthews
Copy link
Contributor Author

Would it be automated through a github action in this repo

Yeah this is likely the best option.

"variables" in Markdown

Well this is cool! But I wonder if it'd work within codeblocks:

Lorem ipsum:

```shell
wget https://ipfs.io/downloads/ipfs-updater-1-18-10.dmg
```

Your process seems logical. We'd probably be able to use the GitHub api to check releases for each major repo (Go-IPFS, IPFS Updater, etc).

@mrodriguez3313
Copy link
Contributor

mrodriguez3313 commented Apr 28, 2022

So I downloaded the repo and made some basic changes. Turns out the "variable" idea still only behaves like url links☹️. If I do [version]:1.8.0 and try to reference it later like [version]. We actually get this behavior [text](url) version

Well this is cool! But I wonder if it'd work within codeblocks:

And it also did not work with codeblocks, it just rendered it literally like [version]

So if the vue variables is not an option, then the script would have to parse every line in the doc 😟

We'd probably be able to use the GitHub api to check releases for each major repo

Looks like that would be simple enough with:
https://docs.github.com/en/rest/releases/releases

@johnnymatthews
Copy link
Contributor Author

Ok nice, so something like:

curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/ipfs/go-ipfs/releases/latest | jq ".tag_name"

Gives us:

"v0.12.2"

Then we just need some funky regex to run on certain pages to find and replace. This python should work:

import re
regex = r"v\d{1,2}\.\d{1,2}\.\d{1,2}"

test_str = ("---\n"
	"title: Command-line\n"
	"description: Using IPFS through the command-line allows you to do everything that IPFS Desktop can do, but at a more granular level since you can specify which commands to run. Learn how to install it here.\n"
	"current-ipfs-version: v0.12.2\n"
[...]
)

subst = "\"v0.12.2\""
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)

if result:
    print (result)

Haven't tested this though.

@mrodriguez3313
Copy link
Contributor

mrodriguez3313 commented Apr 29, 2022

It did work, but I had to remove the [...] bc I was getting this error.

$ python3 scripts/docs-updater.py
scripts/docs-updater.py:4: SyntaxWarning: str indices must be integers or slices, not ellipsis; perhaps you missed a comma?
  test_str = ("---\n"
Traceback (most recent call last):
  File "scripts/docs-updater.py", line 4, in <module>
    test_str = ("---\n"
TypeError: string indices must be integers

Then I changed subst=v0.12.0 just to see if it did anything and it did 👍 and it returned:

---
title: Command-line
description: Using IPFS through the command-line allows you to do everything that IPFS Desktop can do, but at a more granular level since you can specify which commands to run. Learn how to install it here.
current-ipfs-version: "v0.12.0"

I can try extending the script to a given page.

"current-ipfs-version: v0.12.2\n"

I'll start with the ipfs-updater tool, and I won't add anything to the metadata(?, idk what that top portion is called) just yet, but that is perfect to have. Then the next step would be checking against the API and running the script if needed. Which I can also take care of.

@johnnymatthews
Copy link
Contributor Author

I've added the script to PR #1130. Just need to link it up to GitHub actions and we're good to go! Should probably get a Python wiz to review it to (I'm just a lowly docs guys; programming is not my forte).

@mrodriguez3313
Copy link
Contributor

lol now worries. I program well in python, but stackoverflow is our best friend too 😅

@lidel
Copy link
Member

lidel commented Jun 3, 2022

go-ipfs triage notes (cc @BigLep)

@laurentsenta
Copy link
Contributor

laurentsenta commented Jun 6, 2022

Sure,

@mrodriguez3313 @johnnymatthews thanks for looking into this!
What about I review the script you shared, and maybe merge it with the CI code that does the version update for go-ipfs (https://github.com/ipfs/ipfs-docs/pull/1081/files)?

@BigLep
Copy link
Contributor

BigLep commented Jun 6, 2022

Thanks @laurentsenta . Please proceed with any path that reduces the manual steps here :). Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dif/hard Having worked on the specific codebase is important effort/days Estimated to take multiple days, but less than a week need/analysis Needs further analysis before proceeding P2 Medium: Good to have, but can wait until someone steps up
Projects
None yet
5 participants