From 2bed09dd13888a43c41f385217d988c1bac59bac Mon Sep 17 00:00:00 2001 From: plowsof <77655812+plowsof@users.noreply.github.com> Date: Sat, 18 Feb 2023 23:40:12 +0000 Subject: [PATCH 1/2] workflows: grab gitian files from GH + no inputs runid var output docker: get gitian from GH + no runid download artifact repo arg add gitian_if | github changing things cus reasons test prepare-v echo is_v echo == reset found_bin Update main.yml prepare-v or v- Update make_exe.sh echo url output run / gitian id remove quotes debug prepare=1 prepare = 1 output summary checkoutv3 summary print summary print --- .github/workflows/main.yml | 102 ++++++++++++++++++++++++++----------- make_exe.sh | 66 ++++++++++++++++++++---- 2 files changed, 129 insertions(+), 39 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba4573d..b275d48 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,36 +1,76 @@ on: workflow_dispatch: - inputs: - guifile: - description: 'run id' - required: true - default: "3147123066" jobs: GetTag: runs-on: ubuntu-20.04 outputs: output1: ${{ steps.tag.outputs.thetag }} + output2: ${{ steps.tag.outputs.theid }} + output3: ${{ steps.tag.outputs.gitian }} steps: - name: Grab tag from runid (comfy) id: tag run: | - run_id="${{ github.event.inputs.guifile }}" - workflow_run=$(curl \ + get_workflow_runs(){ page=$1 repo=$2 workflow=$3 + FOUND_BIN=0 + PREPARE=0 + DEBUG=https://api.github.com/repos/monero-project/${repo}/actions/runs?page=$page + echo $DEBUG + runs=$(curl \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/monero-project/monero-gui/actions/runs/${run_id}/artifacts) - num=0 - for artifact_name in $(echo ${workflow_run} | jq -r '.artifacts[].name'); do - TAG=$(echo ${workflow_run} | jq -r ".artifacts[${num}].workflow_run.head_branch") - break + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/monero-project/${repo}/actions/runs?page=$page) + + for row in $(echo "${runs}" | jq -r '.workflow_runs[] | @base64'); do + _jq() { + echo ${row} | base64 --decode | jq -r ${1} + } + if [[ $(_jq '.path') = ".github/workflows/$workflow" ]]; then + TAG=$(_jq '.head_branch') + #echo $TAG + is_v=${TAG:0:1} + is_p=${TAG:0:9} + IFS='.' read -ra SPLIT <<< "$TAG" + if [[ $is_p == "prepare-v" ]] || [[ $is_v == "v" ]] && [[ ${#SPLIT[@]} -eq 4 ]]; then + RUNID=$(_jq '.id') + FOUND_BIN=1 + if [[ $is_p = "prepare-v" ]]; then + echo "BUILD prepare in use" + TAG="${TAG/prepare-v/v}" + PREPARE=1 + fi + break + fi + fi done + if [[ $FOUND_BIN -eq 0 ]]; then + ((page+=1)) + get_workflow_runs $page $repo $workflow + else + FOUND_BIN=0 + fi + } + get_workflow_runs 1 monero-gui build.yml echo $TAG - echo "::set-output name=thetag::$TAG" + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + if [[ $PREPARE = 1 ]]; then + echo "Caution: this is a build-prepare not official release" >> $GITHUB_STEP_SUMMARY + fi + echo "theid=$RUNID" >> "$GITHUB_OUTPUT" + echo "thetag=$TAG" >> "$GITHUB_OUTPUT" + echo "tag: ${TAG}" >> $GITHUB_STEP_SUMMARY + echo "runid: ${RUNID}" >> $GITHUB_STEP_SUMMARY + get_workflow_runs 1 monero gitian.yml + echo "gitian=$RUNID" >> "$GITHUB_OUTPUT" + echo "gitianid: ${RUNID}" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + MakeExeWINE: runs-on: ubuntu-20.04 needs: GetTag steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up dependencies run: | sudo apt-add-repository -y ppa:ondrej/php @@ -42,15 +82,17 @@ jobs: - name: "Everything" run: | sudo apt-get install -y jq curl - RUN_ID=${{ github.event.inputs.guifile }} + RUN_ID=${{ needs.GetTag.outputs.output2 }} GH_KEY="${{ secrets.GITHUB_TOKEN }}" TAG=${{needs.GetTag.outputs.output1}} + GITIAN_ID=${{needs.GetTag.outputs.output3}} # Download docker-windows-static - download_artifact(){ run_id=$1 get_name=$2 save_as=$3 gh_key=$4 + download_artifact(){ run_id=$1 repo=$2 get_name=$3 save_as=$4 gh_key=$5 + echo https://api.github.com/repos/monero-project/${repo}/actions/runs/${run_id}/artifacts workflow_run=$(curl \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/monero-project/monero-gui/actions/runs/${run_id}/artifacts) + https://api.github.com/repos/monero-project/${repo}/actions/runs/${run_id}/artifacts) num=0 for artifact_name in $(echo ${workflow_run} | jq -r '.artifacts[].name'); do if [[ "${artifact_name}" == "${get_name}" ]]; then @@ -93,16 +135,16 @@ jobs: cd .. #download artifact also sets the TAG variable - download_artifact $RUN_ID "docker-windows-static" "docker-windows-static" "${GH_KEY}" + download_artifact $RUN_ID monero-gui "docker-windows-static" "docker-windows-static" "${GH_KEY}" + #download gitian cli files + download_artifact $GITIAN_ID monero "Windows" "Windows" "${GH_KEY}" #Extract static files to frombuild unzip "docker-windows-static" -d frombuild + #Extract gitian files here + unzip "Windows" + unzip "monero-x86_64-w64-mingw32-${TAG}.zip" -d clifiles # Download CLI/PDF file(s) - #wget -q "https://gui.xmr.pm/files/cli/${TAG}/monero-win-x64-${TAG}.zip" - wget -q "https://downloads.getmonero.org/cli/win64" -O monero-win-x64-${TAG}.zip - - wget -q "https://github.com/monero-ecosystem/monero-GUI-guide/releases/download/v1.9/monero-gui-wallet-guide.pdf" - unzip "monero-win-x64-${TAG}.zip" -d clifiles # Create lowgfx bat file with heredoc (windows powershell uses \r\n) cr=$'\r' @@ -202,12 +244,14 @@ jobs: - name: Print hashes run: | hash_exe=$(sha256sum bin/monero-gui-install-win-x64-${{needs.GetTag.outputs.output1}}.exe | awk '{print $1}') - echo "Hash of gitian built cli zip:" - sha256sum monero-win-x64-${{needs.GetTag.outputs.output1}}.zip - echo "# ---------------------" - echo "# Monero GUI installer hash:" - echo "# ${hash_exe}" - echo "# ---------------------" + echo "Hash of gitian built cli zip:" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo $(sha256sum monero-x86_64-w64-mingw32-${{needs.GetTag.outputs.output1}}.zip) >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "Monero GUI installer hash:" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "${hash_exe} monero-gui-install-win-x64-${{needs.GetTag.outputs.output1}}.exe" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - name: Archive code coverage results uses: actions/upload-artifact@v3 with: diff --git a/make_exe.sh b/make_exe.sh index 122e929..9c4ee5d 100755 --- a/make_exe.sh +++ b/make_exe.sh @@ -1,15 +1,57 @@ #!/bin/bash -RUN_ID=$1 -GH_KEY=$2 +GH_KEY=$1 # clean up old build dir rm -rf bin +# Get most recent runid from monero/gitian.yml and monero-gui/build.yml +get_workflow_runs(){ page=$1 repo=$2 workflow=$3 + FOUND_BIN=0 + PREPARE=0 + runs=$(curl \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token ${GH_KEY}" \ + https://api.github.com/repos/monero-project/${repo}/actions/runs?page=$page) + + for row in $(echo "${runs}" | jq -r '.workflow_runs[] | @base64'); do + _jq() { + echo ${row} | base64 --decode | jq -r ${1} + } + if [[ $(_jq '.path') = ".github/workflows/$workflow" ]]; then + TAG=$(_jq '.head_branch') + echo $TAG + is_v=${TAG:0:1} + is_p=${TAG:0:9} + IFS='.' read -ra SPLIT <<< "$TAG" + if [[ $is_v = "v" ]] || [[ $is_p = "prepare-v" ]] && [[ ${#SPLIT[@]} -eq 4 ]]; then + RUNID=$(_jq '.id') + FOUND_BIN=1 + if [[ $is_p = "prepare-v" ]]; then + TAG="${TAG/prepare-v/v}" + PREPARE=1 + echo "Tag is now ${TAG}" + fi + break + fi + fi + done + if [[ $FOUND_BIN -eq 0 ]]; then + ((page+=1)) + get_workflow_runs $page $repo $workflow + else + FOUND_BIN=0 + fi +} +get_workflow_runs 1 monero-gui "build.yml" +RUN_ID=$RUNID +get_workflow_runs 1 monero "gitian.yml" +GITIAN_ID=$RUNID + # Download docker-windows-static -download_artifact(){ run_id=$1 get_name=$2 save_as=$3 gh_key=$4 +download_artifact(){ run_id=$1 repo=$2 get_name=$3 save_as=$4 gh_key=$5 workflow_run=$(curl \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/monero-project/monero-gui/actions/runs/${run_id}/artifacts) + https://api.github.com/repos/monero-project/${repo}/actions/runs/${run_id}/artifacts) num=0 for artifact_name in $(echo ${workflow_run} | jq -r '.artifacts[].name'); do if [[ "${artifact_name}" == "${get_name}" ]]; then @@ -52,16 +94,16 @@ done cd .. #download artifact also sets the TAG variable -download_artifact $RUN_ID "docker-windows-static" "docker-windows-static" "${GH_KEY}" +download_artifact $RUN_ID monero-gui "docker-windows-static" "docker-windows-static" "${GH_KEY}" +download_artifact $GITIAN_ID monero "Windows" "Windows" "${GH_KEY}" #Extract static files to frombuild unzip "docker-windows-static" -d frombuild # Download CLI/PDF file(s) #wget -q "https://gui.xmr.pm/files/cli/${TAG}/monero-win-x64-${TAG}.zip" -wget -q "https://downloads.getmonero.org/cli/win64" -O monero-win-x64-${TAG}.zip - +unzip "Windows" wget -q "https://github.com/monero-ecosystem/monero-GUI-guide/releases/download/v1.9/monero-gui-wallet-guide.pdf" -unzip "monero-win-x64-${TAG}.zip" -d clifiles +unzip "monero-x86_64-w64-mingw32-${TAG}.zip" -d clifiles # Create lowgfx bat file with heredoc (windows powershell uses \r\n) cr=$'\r' @@ -169,11 +211,14 @@ mv inno/installers/windows/Output/mysetup.exe "bin/monero-gui-install-win-x64-$ hash_exe=$(sha256sum bin/monero-gui-install-win-x64-${TAG}.exe| awk '{print $1}') echo "Hash of gitian built cli zip:" -sha256sum monero-win-x64-${TAG}.zip +sha256sum monero-x86_64-w64-mingw32-${TAG}.zip echo "# ---------------------" echo "# Monero GUI installer hash:" echo "# ${hash_exe}" echo "# ---------------------" +if [[ $PREPARE -eq 1 ]]; then + echo "Caution: we are using build-prepare script not official tag" +fi # cleanup @@ -182,6 +227,7 @@ rm -rf dummy rm -rf frombuild rm -rf inno rm docker-windows-static -rm "monero-win-x64-${TAG}.zip" +rm Windows +rm *zip rm start-low-graphics-mode.bat rm monero-gui-wallet-guide.pdf From 0d330d203e0d13333079276367929f25205be72f Mon Sep 17 00:00:00 2001 From: plowsof <77655812+plowsof@users.noreply.github.com> Date: Tue, 21 Feb 2023 04:00:18 +0000 Subject: [PATCH 2/2] Update README.md --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ad8a880..4c186d6 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,18 @@ We download the `docker-windows-static` file, then obtain a copy of Monero's 64b After placing all the files correcly and touching them so they have the same modification time as the `monero-wallet-gui.exe` from the `docker-windows-static` zip file, InnoSetup creates the .exe file. -This Repo provides a Github actions file , and also a shell script we can run at home on our ubuntu 20.04 machine (yes, i'll create a docker at some point) which ensures that no 'funny business' is happening on Githubs end. +This Repo provides a Github actions file , and also a shell script we can run at home on our ubuntu 20.04 machine (Which the Dockerfile uses) After running the actions script, you will be presented with the [hash](https://github.com/plowsof/monero-gui-exe/actions/runs/3162064376/jobs/5148317773#step:5:15) and the installer is uploaded at the end. [Seen here in this build of v18.1.2](https://github.com/plowsof/monero-gui-exe/actions/runs/3162064376) The official Monero GUI installer file is created on a windows machine, but we are able to replicate the final hash using Linux and W.I.N.E -To use the `make_exe.sh` script at home, ensure you have an ubuntu with wine / jq / curl / git installed. (pass the runid and a github token with public repo access) +To use the `make_exe.sh` script at home, ensure you have an ubuntu with wine / jq / curl / git installed. (pass the github token with public repo access) ``` -./make_exe.sh 3147123066 ghp_hunter2U*U*u8888**888 +./make_exe.sh ghp_hunter2U*U*u8888**888 ``` Or, you can just fork this repo, and run the actions file -![Screenshot from 2022-10-01 01-15-55](https://user-images.githubusercontent.com/77655812/193374469-2ca675f0-fd43-4462-81de-5b753b8893db.png) ## Docker Clone this repository: @@ -37,11 +36,10 @@ Note: The container is not optimised and its about 3GB ``` docker build -t gui . ``` -Once built you need to run the container and pass it 2 arguments. -1st - runid -2nd - a github token with access to public repositories +Once built you need to run the container and pass it 1 argument. +1. a github token with access to public repositories ``` -docker run -it gui 3147123066 ghp_hunter2U*U*u8888**888 +docker run -it gui ghp_hunter2U*U*u8888**888 ``` At the end you should see something like: ``` @@ -54,4 +52,4 @@ Hash of gitian built cli zip: ``` #### Improvements / TODO's -Currently this can only be used 'after the fact' - when new binaries are uploaded to getmonero. Providing a copy of the Gitian-built CLI binaries is something in process at the moment. This will let people reproduce the installer before it is released. When [this pull request](https://github.com/monero-project/monero/pull/8602) from selsta is merged, we can reproduce/confirm hashes of the installer before it's actually released. +- Package the linux / windows archive files too