diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 25cea73668..9829c75602 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -44,41 +44,50 @@ jobs: - uses: actions/checkout@v4 - run: rustup update - run: rustup target add ${{ matrix.sys.target }} + - if: matrix.sys.target == 'aarch64-unknown-linux-gnu' run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libudev-dev + - name: Setup vars run: | version="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "stellar-cli") | .version')" echo "VERSION=${version}" >> $GITHUB_ENV echo "NAME=${{ matrix.crate.name }}-${version}-${{ matrix.sys.target }}" >> $GITHUB_ENV + - name: Package (release only) if: github.event_name == 'release' run: cargo package --no-verify --package ${{ matrix.crate.name }} + - name: Package Extract (release only) if: github.event_name == 'release' run: | cd target/package tar xvfz ${{ matrix.crate.name }}-$VERSION.crate echo "BUILD_WORKING_DIR=target/package/${{ matrix.crate.name }}-$VERSION" >> $GITHUB_ENV + - name: Build env: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc working-directory: ${{ env.BUILD_WORKING_DIR }} run: cargo build --target-dir="$GITHUB_WORKSPACE/target" --package ${{ matrix.crate.name }} --features opt --release --target ${{ matrix.sys.target }} + - name: Build provenance for attestation (release only) if: github.event_name == 'release' uses: actions/attest-build-provenance@v1 with: subject-path: target/${{ matrix.sys.target }}/release/${{ matrix.crate.binary }}${{ matrix.sys.ext }} + - name: Compress run: | cd target/${{ matrix.sys.target }}/release tar czvf $NAME.tar.gz ${{ matrix.crate.binary }}${{ matrix.sys.ext }} + - name: Upload to Artifacts uses: actions/upload-artifact@v4 with: name: ${{ env.NAME }} path: 'target/${{ matrix.sys.target }}/release/${{ env.NAME }}.tar.gz' + - name: Upload to Release (release only) if: github.event_name == 'release' uses: actions/github-script@v7 @@ -92,3 +101,53 @@ jobs: name: '${{ env.NAME }}.tar.gz', data: fs.readFileSync('target/${{ matrix.sys.target }}/release/${{ env.NAME }}.tar.gz'), }); + + installer: + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Dependencies + run: sudo apt-get update && sudo apt-get -y install nsis wget + + - name: Setup vars + run: | + version="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "stellar-cli") | .version')" + echo "VERSION=${version}" >> $GITHUB_ENV + echo "STELLAR_CLI_INSTALLER=stellar-cli-installer-${{ env.VERSION }}-x86_64-pc-windows-msvc.exe" + + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + name: stellar-cli-${{ inputs.version }}-x86_64-pc-windows-msvc.tar.gz + path: stellar-cli.tar.gz + + - name: Uncompress Artifact + run: tar xvf stellar-cli.tar.gz + + - name: Build Installer + run: | + makensis -V4 -DSTELLAR_CLI_INSTALLER="${{ env.STELLAR_CLI_INSTALLER }}" -DSTELLAR_CLI_VERSION="${{ env.VERSION }}" installer.nsi + + - name: Build provenance for attestation (release only) + if: github.event_name == 'release' + uses: actions/attest-build-provenance@v1 + with: + subject-path: ${{ env.STELLAR_CLI_INSTALLER }} + + - name: Upload to Release (release only) + if: github.event_name == 'release' + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + await github.rest.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: ${{ github.event.release.id }}, + name: '${{ env.STELLAR_CLI_INSTALLER }}', + data: fs.readFileSync('${{ env.STELLAR_CLI_INSTALLER }}'), + }); + diff --git a/installer.nsi b/installer.nsi new file mode 100644 index 0000000000..95c2fb17b5 --- /dev/null +++ b/installer.nsi @@ -0,0 +1,64 @@ +OutFile "${STELLAR_CLI_INSTALLER}" +InstallDir "$PROGRAMFILES\Stellar CLI" +RequestExecutionLevel admin + +; Define WM_SETTINGCHANGE since NSIS doesn’t natively recognize it +!define WM_SETTINGCHANGE 0x1A + +Section "Install" + SetOutPath "$INSTDIR" + File "stellar.exe" + File "stellar.ico" + WriteUninstaller "$INSTDIR\Uninstall.exe" + + ; Create a shortcut in the Start Menu + CreateDirectory "$SMPROGRAMS\Stellar CLI" + CreateShortCut "$SMPROGRAMS\Stellar CLI\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0 + + ; Add an entry to the Windows "Programs and Features" list + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Stellar CLI" "DisplayName" "Stellar CLI" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Stellar CLI" "UninstallString" "$INSTDIR\Uninstall.exe" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Stellar CLI" "DisplayIcon" "$INSTDIR\stellar.ico" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Stellar CLI" "DisplayVersion" "${STELLAR_CLI_VERSION}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Stellar CLI" "Publisher" "Stellar" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Stellar CLI" "InstallLocation" "$INSTDIR" + + ; Add install directory to the PATH + ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" + StrCpy $1 "$0;$INSTDIR" + WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$1" + + ; Notify Windows that the PATH has changed + System::Call 'user32::SendMessageA(i 0xFFFF, i ${WM_SETTINGCHANGE}, i 0, i 0)' +SectionEnd + +Section "Uninstall" + Delete "$INSTDIR\stellar.exe" + Delete "$INSTDIR\Uninstall.exe" + RMDir "$INSTDIR" + + ; Remove the Start Menu shortcut + Delete "$SMPROGRAMS\Stellar CLI\Uninstall.lnk" + RMDir "$SMPROGRAMS\Stellar CLI" + + ; Remove the entry from "Programs and Features" + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Stellar CLI" + + ; Restore PATH without the installation directory + ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" + StrCpy $1 "$0" ; Store the original PATH in $1 + + ; Remove install directory from PATH (manual string removal) + StrLen $2 "$INSTDIR" + loop: + StrCpy $3 "$1" "$2" + StrCmp $3 "$INSTDIR" 0 +3 + StrCpy $1 "$1" "" $2 + goto loop + + ; Write the modified PATH back to registry + WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$1" + + ; Notify Windows that the PATH has changed + System::Call 'user32::SendMessageA(i 0xFFFF, i ${WM_SETTINGCHANGE}, i 0, i 0)' +SectionEnd diff --git a/stellar.ico b/stellar.ico new file mode 100644 index 0000000000..44129184b4 Binary files /dev/null and b/stellar.ico differ