Open friedger opened 4 years ago
That is definitely a direction I considered, I wrote this script before the builds were setup. I would need to figure out how to grab the most current ones each time.
This may not be possible without being authenticated against GitHub, which is undesirable from the viewpoint of this script.
Some more info from searching the Internets:
assets
so cannot use one-liner scripts like this oneartifacts
being the key word (as part of GitHub Action)Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
Sample code that fails:
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/blockstack/stacks-blockchain/actions/artifacts/186057766/zip
{
"message": "You must have the actions scope to download artifacts.",
"documentation_url": "https://developer.github.com/v3/actions/artifacts/#download-an-artifact"
}
edit this may be a possible solution if Blockstack is interested: https://github.com/actions/upload-release-asset
We should ask for proper releases that contain the assets
Jason Schrader notifications@github.com schrieb am Do., 30. Juli 2020, 19:53:
This may not be possible without being authenticated against GitHub, which is undesirable from the viewpoint of this script.
Some more info from searching the Internets:
- Releases do not show https://api.github.com/repos/blockstack/stacks-blockchain/releases/latest assets so cannot use one-liner scripts like this one https://gist.github.com/steinwaywhw/a4cd19cda655b8249d908261a62687f8
- Example of the Artifacts https://github.com/blockstack/stacks-blockchain/actions/runs/186057766 with artifacts being the key word (as part of GitHub Action)
- GitHub documentation on downloading artifacts https://docs.github.com/en/rest/reference/actions#download-an-artifact, however it does say:
Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
Sample code that fails:
curl \ -H "Accept: application/vnd.github.v3+json" \https://api.github.com/repos/blockstack/stacks-blockchain/actions/artifacts/186057766/zip { "message": "You must have the actions scope to download artifacts.", "documentation_url": "https://developer.github.com/v3/actions/artifacts/#download-an-artifact" }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AbsorbingChaos/bks-setup-miner/issues/17#issuecomment-666562821, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALBYWJ74E3HAEB4YIRMLQ3R6GXR7ANCNFSM4O62FJFA .
@friedger I agree, just not sure they are ready for it, see blockstack/stacks-blockchain#1780
If the artifacts could be automatically converted to assets under a release, then it would be much faster to use something pre-compiled for a tool like this shell script, and save us the time of building the code manually.
Update 20200906 - blockstack/stacks-blockchain#1821 is now merged that closes the issue linked above and contains two jobs that should create a release with distributables accessible via a (non-authenticated) script.
stacks-blockchain.yml#L131: # Create a new release if we're building a tag or a tag was passed in
stacks-blockchain.yml#L155: # Upload distributables to a new release if we're building a tag or a tag was passed in
However, at this time these two jobs have been skipped by every run since the master branch has not been updated yet, so we don't have a way to test. My guess is that once the new phase is released we will be able to try this out versus manually building everything! :+1:
Looks like this may officially be possible now!
https://github.com/blockstack/stacks-blockchain/releases/tag/v23.0.0.0-krypton
UPDATE: close, but not quite there, will require some investigation
curl -sS -O https://github.com/blockstack/stacks-blockchain/releases/tag/v23.0.0.0-krypton/linux-x64.zip
sudo apt-get install unzip
unzip linux-x64.zip
results in:
Archive: linux-x64.zip End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of linux-x64.zip or linuz-x64.zip.zip, and cannot find linux-x64.zip.ZIP, period.
I thought the period. was a nice touch at the end.
Link to "latest" release will always be:
https://github.com/blockstack/stacks-blockchain/releases/latest/download/linux-x64.zip
Testing with v23.0.0.3-krypton
release from Linux Mint, able to extract via built-in file manager menu option Extract Here
and using the command-line unzip
utility.
Testing with same release from Ubuntu Server, turns out curl
is downloading a 163 byte file rather than the actual zip file. Add option -L
to get the correct file and unzip works as expected.
Time to implement this in a new version of the script!
Per GH documentation we can grab the latest release info via the API, which includes some info that might help prevent multiple downloads of the same version.
Example:
curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/blockstack/stacks-blockchain/releases/latest | jq .name
output: Release v23.0.0.3-krypton
Other notable fields:
tag_name
= v23.0.0.3-krypton
created_at
= 2020-10-06T14:47:50Z
Assets are available via the json as well, but each contains an ID and it may be easier to just use the URL listed in the previous comment. For example:
assets.name
= linux-arm64.zip
assets.url
= https://api.github.com/repos/blockstack/stacks-blockchain/releases/assets/26615114
First pass, seems to be working!
generate-sk --testnet
, may be releated to #34)./stacks-node start --config=krypton-miner-conf.toml
Per the last comment, storing/comparing tag_name
and created_at
would be a nice first step, followed by using the binary versus building the code.
Debug could still have an option to build the code from stacks-blockchain via #27 or similar.
Download could apply to Mac or Linux
Windows could use a separate batch script?
There are regular nightly builds that could be used.