diff --git a/.github/workflows/iris-wallet-desktop.yml b/.github/workflows/iris-wallet-desktop.yml index 5afdb43..5efae76 100644 --- a/.github/workflows/iris-wallet-desktop.yml +++ b/.github/workflows/iris-wallet-desktop.yml @@ -6,7 +6,7 @@ on: - '*' # Trigger this workflow on any tag push jobs: - build-iris-wallet-desktop: + build-iris-wallet-desktop-linux: runs-on: ubuntu-22.04 steps: - name: Checkout repository with submodules @@ -15,6 +15,26 @@ jobs: submodules: true # Include submodules in the checkout fetch-depth: 1 # Fetch the latest commit only + - name: Validate Tag and Code Version + run: | + TAG_VERSION=$(git describe --tags) + echo "TAG_VERSION=${TAG_VERSION}" >> $GITHUB_ENV + + # Extract version from tag + echo "Tag version: $TAG_VERSION" + + # Extract version from code + CODE_VERSION=$(grep '__version__' ./src/version.py | awk -F'=' '{print $2}' | tr -d ' "' | xargs) + echo "Code version: $CODE_VERSION" + + # Compare the tag and code version + if [ "$TAG_VERSION" != "$CODE_VERSION" ]; then + echo "❌ Tag version ($TAG_VERSION) does not match code version ($CODE_VERSION)." + exit 1 + else + echo "✅ Tag version matches code version." + fi + - name: Install Rust Programming Environment run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y @@ -73,9 +93,10 @@ jobs: VERSION=$(grep '__version__' src/version.py | cut -d "'" -f 2) poetry run build-iris-wallet --network=regtest --distribution=appimage REGTEST_APPIMAGE_NAME="iriswallet-${VERSION}-${ARCH}.AppImage" - RENAME_REGTEST_APPIMAGE_NAME="iriswallet-regtest-${VERSION}-${ARCH}.AppImage" + RENAME_REGTEST_APPIMAGE_NAME="iriswallet-${VERSION}-regtest-${ARCH}.AppImage" mv ${REGTEST_APPIMAGE_NAME} ${RENAME_REGTEST_APPIMAGE_NAME} echo "RENAME_REGTEST_APPIMAGE_NAME=${RENAME_REGTEST_APPIMAGE_NAME}" >> $GITHUB_ENV + chmod +x $RENAME_REGTEST_APPIMAGE_NAME echo "Generated file: $RENAME_REGTEST_APPIMAGE_NAME" shell: bash @@ -91,9 +112,10 @@ jobs: VERSION=$(grep '__version__' src/version.py | cut -d "'" -f 2) poetry run build-iris-wallet --network=testnet --distribution=appimage TESTNET_APPIMAGE_NAME="iriswallet-${VERSION}-${ARCH}.AppImage" - RENAME_TESTNET_APPIMAGE_NAME="iriswallet-testnet-${VERSION}-${ARCH}.AppImage" + RENAME_TESTNET_APPIMAGE_NAME="iriswallet-${VERSION}-testnet-${ARCH}.AppImage" mv ${TESTNET_APPIMAGE_NAME} ${RENAME_TESTNET_APPIMAGE_NAME} echo "RENAME_TESTNET_APPIMAGE_NAME=${RENAME_TESTNET_APPIMAGE_NAME}" >> $GITHUB_ENV + chmod +x $RENAME_TESTNET_APPIMAGE_NAME echo "Generated file: $RENAME_TESTNET_APPIMAGE_NAME" shell: bash @@ -103,10 +125,98 @@ jobs: name: linux_appimage_testnet path: ${{ env.RENAME_TESTNET_APPIMAGE_NAME }} + build-iris-wallet-desktop-macos: + runs-on: macos-latest + steps: + - name: Checkout code with submodules + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 1 + + - name: Validate Tag and Code Version + run: | + TAG_VERSION=$(git describe --tags) + echo "TAG_VERSION=${TAG_VERSION}" >> $GITHUB_ENV + + # Extract version from tag + echo "Tag version: $TAG_VERSION" + + # Extract version from code + CODE_VERSION=$(grep '__version__' ./src/version.py | awk -F'=' '{print $2}' | tr -d ' "' | xargs) + echo "Code version: $CODE_VERSION" + + # Compare the tag and code version + if [ "$TAG_VERSION" != "$CODE_VERSION" ]; then + echo "❌ Tag version ($TAG_VERSION) does not match code version ($CODE_VERSION)." + exit 1 + else + echo "✅ Tag version matches code version." + fi + + - name: Install Rust + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + source "$HOME/.cargo/env" + + - name: Set up Python 3.12.3 + uses: actions/setup-python@v5 + with: + python-version: "3.12.3" + + - name: Clone rgb-lightning-node repository with submodules + run: git clone https://github.com/RGB-Tools/rgb-lightning-node --recurse-submodules --shallow-submodules + + - name: Build the rgb-lightning-node binary + working-directory: rgb-lightning-node + run: cargo install --locked --debug --path . + + - name: Copy rgb-lightning-node binary to root directory + run: | + mkdir ln_node_binary + cp rgb-lightning-node/target/debug/rgb-lightning-node ln_node_binary + + - name: Set environment variables from secrets and create config.py + env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + PROJECT_ID: ${{ secrets.PROJECT_ID }} + AUTH_URI: ${{ secrets.AUTH_URI }} + TOKEN_URI: ${{ secrets.TOKEN_URI }} + AUTH_PROVIDER_CERT_URL: ${{ secrets.AUTH_PROVIDER_CERT_URL }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + run: | + cd src/utils + python generate_config.py + + - name: Install python dependencies + run: | + pip install poetry + pip install pyinstaller + poetry install + + - name: Compile QT resources + run: | + poetry run pyside6-rcc src/resources.qrc -o src/resources_rc.py + + - name: Build the application + run: | + # Build the regtest application for macOS + poetry run build-iris-wallet --network=regtest + + # Build the testnet application for macOS + poetry run build-iris-wallet --network=testnet + + - name: Upload macOS artifact + uses: actions/upload-artifact@v4 + with: + name: macos + path: iriswallet-* + release-artifacts: - if: needs.build-iris-wallet-desktop.result == 'success' - runs-on: ubuntu-latest - needs: [build-iris-wallet-desktop] + if: needs.build-iris-wallet-desktop-macos.result == 'success' && needs.build-iris-wallet-desktop-linux.result == 'success' + runs-on: ubuntu-24.04 + needs: [build-iris-wallet-desktop-macos, build-iris-wallet-desktop-linux] permissions: contents: write steps: @@ -119,66 +229,62 @@ jobs: echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV echo "Using tag: $TAG_NAME" - - name: Create GitHub Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: "${{ env.TAG_NAME }}" - release_name: "${{ env.TAG_NAME }}" - draft: false - prerelease: false - - - name: Read version and architecture information - run: | - VERSION=$(grep '__version__' src/version.py | cut -d "'" -f 2) - ARCH=$(uname -m) - TESTNET_APPIMAGE_NAME="iriswallet-testnet-${VERSION}-${ARCH}.AppImage" - REGTEST_APPIMAGE_NAME="iriswallet-regtest-${VERSION}-${ARCH}.AppImage" - echo "ARCH=${ARCH}" >> $GITHUB_ENV - echo "TESTNET_APPIMAGE_NAME=${TESTNET_APPIMAGE_NAME}" >> $GITHUB_ENV - echo "REGTEST_APPIMAGE_NAME=${REGTEST_APPIMAGE_NAME}" >> $GITHUB_ENV - - name: Prepare uploads folder run: mkdir -p ./uploads + - name: Download macOS artifact + uses: actions/download-artifact@v4 + with: + name: macos # Name of the macOS artifact + path: ./uploads # Destination path folder + - name: Download Testnet AppImage artifact uses: actions/download-artifact@v4 with: name: linux_appimage_testnet - path: ./uploads/testnet + path: ./uploads - name: Download Regtest AppImage artifact uses: actions/download-artifact@v4 with: name: linux_appimage_regtest - path: ./uploads/regtest + path: ./uploads - - name: Upload Testnet AppImage to GitHub Release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./uploads/testnet/${{ env.TESTNET_APPIMAGE_NAME }} - asset_name: iris-wallet-${{ env.TAG_NAME }}-testnet-${{env.ARCH}}.AppImage - asset_content_type: application/octet-stream + - name: Extract Version and Artifacts Info + run: | + VERSION=$(grep '__version__' src/version.py | cut -d "'" -f 2) - - name: Upload Regtest AppImage to GitHub Release - uses: actions/upload-release-asset@v1 + echo "TESTNET_APPIMAGE_NAME=${TESTNET_APPIMAGE_NAME}" >> $GITHUB_ENV + echo "REGTEST_APPIMAGE_NAME=${REGTEST_APPIMAGE_NAME}" >> $GITHUB_ENV + + cd uploads + REGTEST_APPNAME_MAC=$(ls iriswallet-${VERSION}-regtest-*.dmg 2>/dev/null || echo "") + TESTNET_APPNAME_MAC=$(ls iriswallet-${VERSION}-testnet-*.dmg 2>/dev/null || echo "") + + TESTNET_APPIMAGE_NAME=$(ls iriswallet-${VERSION}-regtest-*.AppImage 2>/dev/null || echo "") + REGTEST_APPIMAGE_NAME=$(ls iriswallet-${VERSION}-testnet-*.AppImage 2>/dev/null || echo "") + + echo "REGTEST_APPNAME_MAC=${REGTEST_APPNAME_MAC}" >> $GITHUB_ENV + echo "TESTNET_APPNAME_MAC=${TESTNET_APPNAME_MAC}" >> $GITHUB_ENV + echo "REGTEST_APPIMAGE_NAME=${REGTEST_APPIMAGE_NAME}" >> $GITHUB_ENV + echo "TESTNET_APPIMAGE_NAME=${TESTNET_APPIMAGE_NAME}" >> $GITHUB_ENV + + - name: Create GitHub Release and Upload Assets + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.TAG_NAME }} + files: | + ./uploads/${{ env.REGTEST_APPNAME_MAC }} + ./uploads/${{ env.TESTNET_APPNAME_MAC }} + ./uploads/${{ env.TESTNET_APPIMAGE_NAME }} + ./uploads/${{ env.REGTEST_APPIMAGE_NAME }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./uploads/regtest/${{ env.REGTEST_APPIMAGE_NAME }} - asset_name: iris-wallet-${{ env.TAG_NAME }}-regtest-${{env.ARCH}}.AppImage - asset_content_type: application/octet-stream cleanup-artifacts: if: always() - runs-on: ubuntu-latest - needs: [build-iris-wallet-desktop, release-artifacts] + runs-on: ubuntu-22.04 + needs: [build-iris-wallet-desktop-macos, build-iris-wallet-desktop-linux, release-artifacts] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -187,6 +293,7 @@ jobs: uses: geekyeggo/delete-artifact@v5 with: name: | + macos linux_appimage_regtest linux_appimage_testnet failOnError: false diff --git a/build_macos.sh b/build_macos.sh index 58d06e9..b176d5d 100755 --- a/build_macos.sh +++ b/build_macos.sh @@ -3,6 +3,8 @@ # Getting the app name and version from version.py and constant.py. APP_NAME=$(grep 'APP_NAME' ./src/utils/constant.py | awk -F'=' '{print $2}' | tr -d ' "' | xargs) VERSION=$(grep '__version__' ./src/version.py | awk -F'=' '{print $2}' | tr -d ' "' | xargs) +BITCOIN_NETWORK=$(grep '__network__' ./src/flavour.py | awk -F'=' '{print $2}' | tr -d ' "' | xargs) +ARCH=$(uname -m) # Check if APP_NAME and VERSION are non-empty @@ -33,9 +35,23 @@ ls -l "${DIST_PATH}" if [ -d "${APP_BUNDLE}" ]; then echo "App bundle created successfully." echo "Creating DMG file..." + + # Create the DMG and capture the output directory npx create-dmg --dmg-title="${APP_NAME}-${VERSION}" "${APP_BUNDLE}" - echo "DMG file created successfully." + # Locate the newly created DMG file in the current directory + DMG_FILE=$(ls -1t *.dmg | head -n 1) + + if [ -f "${DMG_FILE}" ]; then + echo "DMG file created: ${DMG_FILE}" + + # Rename the DMG file + NEW_DMG_NAME="${APP_NAME}-${VERSION}-${BITCOIN_NETWORK}-${ARCH}.dmg" + mv "${DMG_FILE}" "${NEW_DMG_NAME}" + echo "DMG file renamed to: ${NEW_DMG_NAME}" + else + echo "Failed to locate the DMG file." + fi echo "Removing app bundle..." rm -rf "${DIST_PATH}"