Closed johnnymatthews closed 2 years ago
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:
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
Would it be automated through a github action in this repo
Yeah this is likely the best option.
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).
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
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.
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 :thumbsup: 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.
I've added the script to PR https://github.com/ipfs/ipfs-docs/pull/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).
lol now worries. I program well in python, but stackoverflow is our best friend too 😅
go-ipfs triage notes (cc @BigLep)
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)?
Thanks @laurentsenta . Please proceed with any path that reduces the manual steps here :). Thank you!
Throughout this repo we reference specific version numbers for things like Go-IPFS and IPFS Updater.
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:
We can use this issue to discuss the best way of creating this script.