diff --git a/.github/workflows/build-dev.yaml b/.github/workflows/build-dev.yaml index b1ee4d61da..18ab636c4d 100644 --- a/.github/workflows/build-dev.yaml +++ b/.github/workflows/build-dev.yaml @@ -25,74 +25,71 @@ env: GIT_VERSION: 1 jobs: - linux-x64: + build: runs-on: ubuntu-latest + container: defi/ain-builder:latest + strategy: + matrix: + target: [x86_64-pc-linux-gnu, x86_64-w64-mingw32, x86_64-apple-darwin] env: - TARGET: x86_64-pc-linux-gnu + TARGET: ${{matrix.target}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - name: Populate environment run: ./make.sh ci-export-vars - - name: Build and package - run: ./make.sh docker-release + - name: Setup dependencies + run: ./make.sh ci-setup-deps + + - name: Setup user dependencies + run: ./make.sh ci-setup-user-deps - - name: Publish artifact - x86_64-pc-linux-gnu - uses: actions/upload-artifact@v3 + - uses: Swatinem/rust-cache@v2 with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ env.DOCKER_HUB_USER }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - - - name: Push to Docker Hub - run: | - set -e; ver=${{ env.BUILD_VERSION }} - docker tag defichain-x86_64-pc-linux-gnu:${ver} defi/defichain:${ver} - docker push defi/defichain:${ver} - - win-x64: - runs-on: ubuntu-latest - env: - TARGET: x86_64-w64-mingw32 - - steps: - - uses: actions/checkout@v3 - - - name: Populate environment - run: ./make.sh ci-export-vars + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} - name: Build and package - run: ./make.sh docker-release + run: ./make.sh release - - name: Publish artifact - x86_64-w64-mingw32 + - name: Publish artifact uses: actions/upload-artifact@v3 with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32 - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.tar.gz + name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }} + path: ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} - osx-x64: + docker-build: runs-on: ubuntu-latest + needs: [build] env: - TARGET: x86_64-apple-darwin + TARGET: x86_64-pc-linux-gnu steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - name: Populate environment run: ./make.sh ci-export-vars - - name: Build and package - run: ./make.sh docker-release + - name: Download Binaries + uses: actions/download-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }} - - name: Publish artifact - x86_64-apple-darwin - uses: actions/upload-artifact@v3 + - name: Build defi image + run: rm .dockerignore && ./make.sh docker-defi-build + + - name: Login to Docker Hub + uses: docker/login-action@v2 with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz + username: ${{ env.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Push to Docker Hub + run: | + set -e; ver=${{ env.BUILD_VERSION }} + docker tag defichain-${{ env.TARGET }}:${ver} defi/defichain:${ver} + docker push defi/defichain:${ver} diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 43f8d4f769..6c4cba3507 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -12,153 +12,44 @@ env: GIT_VERSION: 1 jobs: - linux-x64: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - env: - TARGET: x86_64-pc-linux-gnu - - steps: - - uses: actions/checkout@v4 - - - name: Populate environment - run: ./make.sh ci-export-vars - - - name: Build and package - run: ./make.sh docker-release - - - name: Publish artifacts - uses: actions/upload-artifact@v3 - with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ env.DOCKER_HUB_USER }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - - - name: Push to Docker Hub - run: | - set -e; ver=${{ env.BUILD_VERSION }} - for tag in $(echo $ver latest); do - docker tag defichain-x86_64-pc-linux-gnu:${ver} defi/defichain:${tag} - done - docker push defi/defichain:${ver} - - linux-aarch64: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - env: - TARGET: aarch64-linux-gnu - - steps: - - uses: actions/checkout@v4 - - - name: Populate environment - run: ./make.sh ci-export-vars - - - name: Build and package - run: ./make.sh docker-release - - - name: Publish artifact - aarch64-linux-gnu - uses: actions/upload-artifact@v3 - with: - name: defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu - path: ./build/defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz - - win-x64: + create-release: runs-on: ubuntu-latest + container: defi/ain-builder:latest if: startsWith(github.ref, 'refs/tags/') + strategy: + matrix: + target: [x86_64-pc-linux-gnu, aarch64-linux-gnu, x86_64-w64-mingw32, x86_64-apple-darwin, aarch64-apple-darwin] env: - TARGET: x86_64-w64-mingw32 + TARGET: ${{matrix.target}} steps: - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - name: Populate environment run: ./make.sh ci-export-vars - - name: Build and package - run: ./make.sh docker-release + - name: Setup dependencies + run: ./make.sh ci-setup-deps + + - name: Setup user dependencies + run: ./make.sh ci-setup-user-deps - - name: Publish artifact - x86_64-w64-mingw32 - uses: actions/upload-artifact@v3 + - uses: Swatinem/rust-cache@v2 with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32 - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.tar.gz - - osx-x64: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - env: - TARGET: x86_64-apple-darwin - - steps: - - uses: actions/checkout@v4 - - - name: Populate environment - run: ./make.sh ci-export-vars + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} - name: Build and package - run: ./make.sh docker-release + run: ./make.sh release - - name: Publish artifact - x86_64-apple-darwin + - name: Publish artifact uses: actions/upload-artifact@v3 with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz - - osx-aarch64: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - env: - TARGET: aarch64-apple-darwin - - steps: - - uses: actions/checkout@v4 - - - name: Populate environment - run: ./make.sh ci-export-vars - - - name: Build and package - run: ./make.sh docker-release - - - name: Publish artifact - aarch64-apple-darwin - uses: actions/upload-artifact@v3 - with: - name: defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin - path: ./build/defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz - - create-release: - needs: - - linux-x64 - - linux-aarch64 - - win-x64 - - osx-x64 - - osx-aarch64 - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - - steps: - - uses: actions/checkout@v4 - - - name: Populate environment - run: ./make.sh ci-export-vars - - - name: Cleanup work dir - run: rm -rf * - - - name: Get artifacts - uses: actions/download-artifact@v3 - - - name: zip package for win-x64 - run: | - set -e; ver=${{ env.BUILD_VERSION }} - cd defichain-${ver}-x86_64-w64-mingw32 - tar xzf defichain-${ver}-x86_64-w64-mingw32.tar.gz - zip -r "defichain-${ver}-x86_64-w64-mingw32.zip" defichain-${ver}/ + name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }} + path: | + ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} + ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }}.SHA256 - name: Get release id: get_release @@ -166,116 +57,55 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Generate SHA256 checksum - run: | - set -e; ver=${{ env.BUILD_VERSION }} - (cd ./defichain-${ver}-x86_64-pc-linux-gnu - sha256sum ./defichain-${ver}-x86_64-pc-linux-gnu.tar.gz > ./defichain-${ver}-x86_64-pc-linux-gnu.tar.gz.SHA256) - (cd ./defichain-${ver}-aarch64-linux-gnu - sha256sum ./defichain-${ver}-aarch64-linux-gnu.tar.gz > ./defichain-${ver}-aarch64-linux-gnu.tar.gz.SHA256) - (cd ./defichain-${ver}-x86_64-w64-mingw32 - sha256sum ./defichain-${ver}-x86_64-w64-mingw32.zip > ./defichain-${ver}-x86_64-w64-mingw32.zip.SHA256) - (cd ./defichain-${ver}-x86_64-apple-darwin - sha256sum ./defichain-${ver}-x86_64-apple-darwin.tar.gz > ././defichain-${ver}-x86_64-apple-darwin.tar.gz.SHA256) - (cd ./defichain-${ver}-aarch64-apple-darwin - sha256sum ./defichain-${ver}-aarch64-apple-darwin.tar.gz > ././defichain-${ver}-aarch64-apple-darwin.tar.gz.SHA256) - - - name: Upload release asset - linux-x64 + - name: Upload release asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu/defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz - asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz + asset_path: ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} + asset_name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} asset_content_type: application/gzip - - name: Upload checksum - linux-x64 + - name: Upload checksum uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu/defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz.SHA256 - asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz.SHA256 + asset_path: ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }}.SHA256 + asset_name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }}.SHA256 asset_content_type: text/plain - - name: Upload release asset - linux-aarch64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu/defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz - asset_name: defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz - asset_content_type: application/gzip - - - name: Upload checksum - linux-aarch64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu/defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz.SHA256 - asset_name: defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz.SHA256 - asset_content_type: text/plain + create-docker-release: + runs-on: ubuntu-latest + needs: [create-release] + env: + TARGET: x86_64-pc-linux-gnu - - name: Upload release asset - win-x64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32/defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.zip - asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.zip - asset_content_type: application/zip + steps: + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - - name: Upload checksum asset - win-x64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32/defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.zip.SHA256 - asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.zip.SHA256 - asset_content_type: text/plain + - name: Populate environment + run: ./make.sh ci-export-vars - - name: Upload release asset - osx-x64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Download Binaries + uses: actions/download-artifact@v3 with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz - asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz - asset_content_type: application/gzip + name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }} - - name: Upload checksum asset - osx-x64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz.SHA256 - asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz.SHA256 - asset_content_type: text/plain - - - name: Upload release asset - osx-aarch64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin/defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz - asset_name: defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz - asset_content_type: application/gzip + - name: Build defi image + run: rm .dockerignore && ./make.sh docker-defi-build - - name: Upload checksum asset - osx-aarch64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Login to Docker Hub + uses: docker/login-action@v2 with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin/defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz.SHA256 - asset_name: defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz.SHA256 - asset_content_type: text/plain + username: ${{ env.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Push to Docker Hub + run: | + set -e; ver=${{ env.BUILD_VERSION }} + docker tag defichain-${{ env.TARGET }}:${ver} defi/defichain:${ver} + docker push defi/defichain:${ver} diff --git a/.github/workflows/build-staging.yaml b/.github/workflows/build-staging.yaml index fe56c3d076..c75c626ca3 100644 --- a/.github/workflows/build-staging.yaml +++ b/.github/workflows/build-staging.yaml @@ -8,148 +8,64 @@ env: GIT_VERSION: 1 jobs: - linux-x64: + # We keep the flow as similar as close to release flow as possible + # to validate change before it gets into release, even though + # these don't create end artifacts to use + stage-release: runs-on: ubuntu-latest + container: defi/ain-builder:latest + strategy: + matrix: + target: [x86_64-pc-linux-gnu, aarch64-linux-gnu, x86_64-w64-mingw32, x86_64-apple-darwin, aarch64-apple-darwin] env: - TARGET: x86_64-pc-linux-gnu + TARGET: ${{matrix.target}} steps: - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - name: Populate environment run: ./make.sh ci-export-vars - - name: Build and package - run: ./make.sh docker-release - - - name: Publish artifacts - uses: actions/upload-artifact@v3 - with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz + - name: Setup dependencies + run: ./make.sh ci-setup-deps - linux-aarch64: - runs-on: ubuntu-latest - env: - TARGET: aarch64-linux-gnu - - steps: - - uses: actions/checkout@v4 - - - name: Populate environment - run: ./make.sh ci-export-vars - - - name: Build and package - run: ./make.sh docker-release + - name: Setup user dependencies + run: ./make.sh ci-setup-user-deps - - name: Publish artifact - aarch64-linux-gnu - uses: actions/upload-artifact@v3 + - uses: Swatinem/rust-cache@v2 with: - name: defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu - path: ./build/defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz - - win-x64: - runs-on: ubuntu-latest - env: - TARGET: x86_64-w64-mingw32 - - steps: - - uses: actions/checkout@v4 - - - name: Populate environment - run: ./make.sh ci-export-vars + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} - name: Build and package - run: ./make.sh docker-release + run: ./make.sh release - - name: Publish artifact - x86_64-w64-mingw32 + - name: Publish artifact uses: actions/upload-artifact@v3 with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32 - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.tar.gz + name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }} + path: | + ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }} + ./build/defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }}.${{ env.PKG_TYPE }}.SHA256 - osx-x64: + stage-docker-release: runs-on: ubuntu-latest + needs: [stage-release] env: - TARGET: x86_64-apple-darwin - - steps: - - uses: actions/checkout@v4 - - - name: Populate environment - run: ./make.sh ci-export-vars - - - name: Build and package - run: ./make.sh docker-release - - - name: Publish artifact - x86_64-apple-darwin - uses: actions/upload-artifact@v3 - with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz - - osx-aarch64: - runs-on: ubuntu-latest - env: - TARGET: aarch64-apple-darwin - - steps: - - uses: actions/checkout@v4 - - - name: Populate environment - run: ./make.sh ci-export-vars - - - name: Build and package - run: ./make.sh docker-release - - - name: Publish artifact - aarch64-apple-darwin - uses: actions/upload-artifact@v3 - with: - name: defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin - path: ./build/defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz - - # We keep the flow as similar as close to release flow as possible - # to validate change before it gets into release, even though - # these don't create end artifacts to use - - stage-release: - needs: - - linux-x64 - - linux-aarch64 - - win-x64 - - osx-x64 - - osx-aarch64 - runs-on: ubuntu-latest + TARGET: x86_64-pc-linux-gnu steps: - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - name: Populate environment run: ./make.sh ci-export-vars - - name: Cleanup work dir - run: rm -rf * - - - name: Get artifacts + - name: Download Binaries uses: actions/download-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-${{ env.TARGET }} - - name: zip package for win-x64 - run: | - set -e; ver=${{ env.BUILD_VERSION }} - cd defichain-${ver}-x86_64-w64-mingw32 - tar xzf defichain-${ver}-x86_64-w64-mingw32.tar.gz - zip -r "defichain-${ver}-x86_64-w64-mingw32.zip" defichain-${ver}/ - - - name: Generate SHA256 checksum - run: | - set -e; ver=${{ env.BUILD_VERSION }} - (cd ./defichain-${ver}-x86_64-pc-linux-gnu - sha256sum ./defichain-${ver}-x86_64-pc-linux-gnu.tar.gz > ./defichain-${ver}-x86_64-pc-linux-gnu.tar.gz.SHA256) - (cd ./defichain-${ver}-aarch64-linux-gnu - sha256sum ./defichain-${ver}-aarch64-linux-gnu.tar.gz > ./defichain-${ver}-aarch64-linux-gnu.tar.gz.SHA256) - (cd ./defichain-${ver}-x86_64-w64-mingw32 - sha256sum ./defichain-${ver}-x86_64-w64-mingw32.zip > ./defichain-${ver}-x86_64-w64-mingw32.zip.SHA256) - (cd ./defichain-${ver}-x86_64-apple-darwin - sha256sum ./defichain-${ver}-x86_64-apple-darwin.tar.gz > ././defichain-${ver}-x86_64-apple-darwin.tar.gz.SHA256) - (cd ./defichain-${ver}-aarch64-apple-darwin - sha256sum ./defichain-${ver}-aarch64-apple-darwin.tar.gz > ././defichain-${ver}-aarch64-apple-darwin.tar.gz.SHA256) + - name: Build defi image + run: rm .dockerignore && ./make.sh docker-defi-build diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index a1bba7be3c..da86d4ef83 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -29,7 +29,7 @@ jobs: PYTHON: 3.8 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Lint run: ./ci/lint/main.sh @@ -45,7 +45,7 @@ jobs: CARGO_INCREMENTAL: 0 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - run: git config --global --add safe.directory '*' - name: Populate environment diff --git a/.github/workflows/tests-ethlibs.yaml b/.github/workflows/tests-ethlibs.yaml index dd7f9abcab..1bdf74a8f4 100644 --- a/.github/workflows/tests-ethlibs.yaml +++ b/.github/workflows/tests-ethlibs.yaml @@ -15,15 +15,19 @@ concurrency: env: NODE_URL: "http://127.0.0.1:19551/" + TARGET: x86_64-pc-linux-gnu + MAKE_DEBUG: 0 jobs: build: - env: - CARGO_INCREMENTAL: 0 runs-on: ubuntu-latest container: defi/ain-builder:latest + env: + CARGO_INCREMENTAL: 0 + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - name: Populate environment run: ./make.sh ci-export-vars @@ -31,7 +35,7 @@ jobs: - name: Setup dependencies run: ./make.sh ci-setup-deps - - name: Setup dependencies for user + - name: Setup user dependencies run: ./make.sh ci-setup-user-deps - uses: Swatinem/rust-cache@v2 @@ -83,7 +87,7 @@ jobs: go-version: '^1.17.0' - name: Setup go-ethlibs test suites - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'DeFiCh/go-ethlibs' diff --git a/.github/workflows/tests-frontier.yml b/.github/workflows/tests-frontier.yml index 6e75bf666b..fd389b0152 100644 --- a/.github/workflows/tests-frontier.yml +++ b/.github/workflows/tests-frontier.yml @@ -12,19 +12,22 @@ concurrency: jobs: build: + runs-on: ubuntu-latest + container: defi/ain-builder:latest env: CARGO_INCREMENTAL: 0 - runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - name: Populate environment run: ./make.sh ci-export-vars - name: Setup dependencies - run: sudo ./make.sh ci-setup-deps + run: ./make.sh ci-setup-deps - - name: Setup dependencies for user + - name: Setup user dependencies run: ./make.sh ci-setup-user-deps - uses: Swatinem/rust-cache@v2 @@ -39,17 +42,15 @@ jobs: uses: actions/upload-artifact@v3 with: name: defi-bins - path: | - build/src/defid + path: build/src/defid test: name: Frontier tests runs-on: ubuntu-latest - needs: build steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: defich/metachain-ts-tests ref: 'main' diff --git a/.github/workflows/tests-jellyfish.yml b/.github/workflows/tests-jellyfish.yml index 21c0c1c9fe..a4735abd5a 100644 --- a/.github/workflows/tests-jellyfish.yml +++ b/.github/workflows/tests-jellyfish.yml @@ -17,13 +17,14 @@ jobs: test: name: Test runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: JellyfishSDK/jellyfish ref: 'main' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: defichain diff --git a/.github/workflows/tests-sync.yml b/.github/workflows/tests-sync.yml index 6158c902d8..22fde03602 100644 --- a/.github/workflows/tests-sync.yml +++ b/.github/workflows/tests-sync.yml @@ -28,7 +28,8 @@ jobs: env: CARGO_INCREMENTAL: 0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - name: Populate environment run: ./make.sh ci-export-vars @@ -36,7 +37,7 @@ jobs: - name: Setup dependencies run: sudo ./make.sh ci-setup-deps - - name: Setup dependencies for user + - name: Setup user dependencies run: ./make.sh ci-setup-user-deps - uses: Swatinem/rust-cache@v2 @@ -44,8 +45,6 @@ jobs: workspaces: lib -> ../build/lib/target save-if: ${{ github.ref == 'refs/heads/master' }} - # TODO: Switch this to a docker build later and this builds on the native - # VM toolchain and loses disparity with the CI release builds - name: Build binaries run: ./make.sh build @@ -54,8 +53,8 @@ jobs: with: name: defi-bins path: | - build/src/defid - build/src/defi-cli + build/src/defid + build/src/defi-cli - name: Upload shell commands uses: actions/upload-artifact@v3 @@ -76,7 +75,8 @@ jobs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - id: 'auth' name: 'Authenticate to Google Cloud' @@ -119,7 +119,8 @@ jobs: timeout-minutes: 4320 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory '*' - name: Download Snapshot run: aria2c -x16 -s16 https://storage.googleapis.com/team-drop/master-datadir/datadir-${{matrix.blocks.start}}.tar.gz diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 69ea0c3070..faaf4ff257 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -24,14 +24,15 @@ jobs: TESTS_FAILFAST: 0 TESTS_COMBINED_LOGS: 500 CARGO_INCREMENTAL: 0 + steps: - name: Checkout base branch and/or merge if: github.event_name != 'pull_request' - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Checkout pull request head commit if: github.event_name == 'pull_request' - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} @@ -41,7 +42,7 @@ jobs: - name: Install dependencies run: ./make.sh ci-setup-deps - - name: Setup dependencies for user + - name: Setup user dependencies run: ./make.sh ci-setup-user-deps - uses: Swatinem/rust-cache@v2 @@ -49,7 +50,7 @@ jobs: workspaces: lib -> ../build/lib/target save-if: ${{ github.ref == 'refs/heads/master' }} - - name: Build deps and configure + - name: Build binaries run: ./make.sh build # Temp. workaround to save space to prevent GH runners from running out @@ -64,7 +65,7 @@ jobs: container: defi/ain-builder:latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Populate environment run: ./make.sh ci-export-vars diff --git a/contrib/dockerfiles/defi.dockerfile b/contrib/dockerfiles/defi.dockerfile new file mode 100644 index 0000000000..40db80d80a --- /dev/null +++ b/contrib/dockerfiles/defi.dockerfile @@ -0,0 +1,24 @@ +ARG TARGET=x86_64-pc-linux-gnu + +FROM --platform=linux/amd64 ubuntu:latest as defi +ARG TARGET +ARG PACKAGE +ENV PATH=/app/bin:$PATH +LABEL org.defichain.name="defichain" +LABEL org.defichain.arch=${TARGET} + +WORKDIR /app +COPY ${PACKAGE} ./ +RUN tar -xvzf ${PACKAGE} --strip-components 1 + +RUN useradd --create-home defi && \ + mkdir -p /data && \ + chown defi:defi /data && \ + ln -s /data /home/defi/.defi + +VOLUME ["/data"] + +USER defi:defi +CMD [ "/app/bin/defid" ] + +EXPOSE 8554 8550 8551 18554 18550 18551 19554 19550 19551 20554 20550 20551 diff --git a/contrib/dockerfiles/noarch.dockerfile b/contrib/dockerfiles/noarch.dockerfile index 9393ce7bdc..1ee1aa8db0 100644 --- a/contrib/dockerfiles/noarch.dockerfile +++ b/contrib/dockerfiles/noarch.dockerfile @@ -4,7 +4,7 @@ ARG TARGET=unknown # ----------- -FROM ubuntu:latest as builder +FROM --platform=linux/amd64 ubuntu:latest as builder ARG TARGET ARG MAKE_DEBUG LABEL org.defichain.name="defichain-builder" diff --git a/contrib/genbuild.sh b/contrib/genbuild.sh index 47b12a2600..ba751e796b 100755 --- a/contrib/genbuild.sh +++ b/contrib/genbuild.sh @@ -25,7 +25,7 @@ git_check_in_repo() { DESC="" SUFFIX="" CURRENT_BRANCH="" -if [ -z "$BUILD_VERSION" ] && [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo contrib/genbuild.sh; then +if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo contrib/genbuild.sh; then # clean 'dirty' status of touched files that haven't been modified git diff >/dev/null 2>/dev/null @@ -55,9 +55,7 @@ if [ -z "$BUILD_VERSION" ] && [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$ git diff-index --quiet HEAD -- || SUFFIX="$SUFFIX-dirty" fi -if [ -n "$BUILD_VERSION" ]; then - NEWINFO="#define BUILD_DESC \"$BUILD_VERSION\"" -elif [ -n "$DESC" ]; then +if [ -n "$DESC" ]; then NEWINFO="#define BUILD_DESC \"$DESC\"" elif [ -n "$SUFFIX" ]; then NEWINFO="#define BUILD_SUFFIX $SUFFIX" diff --git a/make.sh b/make.sh index 7e8155ea1b..832873a696 100755 --- a/make.sh +++ b/make.sh @@ -19,6 +19,7 @@ setup_vars() { DOCKER_ROOT_CONTEXT=${DOCKER_ROOT_CONTEXT:-"."} DOCKERFILES_DIR=${DOCKERFILES_DIR:-"./contrib/dockerfiles"} + DEFI_DOCKERFILE=${DEFI_DOCKERFILE:-"${DOCKERFILES_DIR}/defi.dockerfile"} ROOT_DIR="$(_canonicalize "${_SCRIPT_DIR}")" @@ -219,10 +220,13 @@ package() { local build_dir="${BUILD_DIR}" local pkg_name="${img_prefix}-${img_version}-${target}" - local pkg_tar_file_name="${pkg_name}.tar.gz" local pkg_path - pkg_path="$(_canonicalize "${build_dir}/${pkg_tar_file_name}")" + if [[ "$target" == "x86_64-w64-mingw32" ]]; then + pkg_path="$(_canonicalize "${build_dir}/${pkg_name}.zip")" + else + pkg_path="$(_canonicalize "${build_dir}/${pkg_name}.tar.gz")" + fi local versioned_name="${img_prefix}-${img_version}" local versioned_build_dir="${build_dir}/${versioned_name}" @@ -235,8 +239,14 @@ package() { echo "> packaging: ${pkg_name} from ${versioned_build_dir}" - _ensure_enter_dir "${versioned_build_dir}" - _tar --transform "s,^./,${versioned_name}/," -czf "${pkg_path}" ./* + if [[ "$target" == "x86_64-w64-mingw32" ]]; then + _ensure_enter_dir "${build_dir}" + zip -r "${pkg_path}" "${versioned_build_dir}/" + else + _ensure_enter_dir "${versioned_build_dir}" + _tar --transform "s,^./,${versioned_name}/," -czf "${pkg_path}" ./* + fi + sha256sum "${pkg_path}" > "${pkg_path}.SHA256" _exit_dir echo "> package: ${pkg_path}" @@ -282,7 +292,6 @@ docker_deploy() { local img="${img_prefix}-${target}:${img_version}" echo "> deploy from: ${img}" - local pkg_name="${img_prefix}-${img_version}-${target}" local versioned_name="${img_prefix}-${img_version}" local versioned_build_dir="${build_dir}/${versioned_name}" @@ -311,6 +320,27 @@ docker_release() { _sign "$target" } +docker_defi_build() { + local target=${1:-${TARGET}} + local img_prefix="${IMAGE_PREFIX}" + local img_version="${IMAGE_VERSION}" + + local pkg_name="${img_prefix}-${img_version}-${target}.tar.gz" + + local docker_context="${DOCKER_ROOT_CONTEXT}" + local docker_file="${DEFI_DOCKERFILE}" + + echo "> docker-defi-build"; + + local img="${img_prefix}-${target}:${img_version}" + echo "> building: ${img}" + echo "> docker defi build: ${img}" + + docker build -f "${docker_file}" \ + --build-arg PACKAGE="${pkg_name}" \ + -t "${img}" "${docker_context}" +} + docker_clean_builds() { echo "> clean: defichain build images" _docker_clean "org.defichain.name=defichain" @@ -661,7 +691,7 @@ pkg_install_deps() { libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev \ libminiupnpc-dev libzmq3-dev libqrencode-dev wget \ libdb-dev libdb++-dev libdb5.3 libdb5.3-dev libdb5.3++ libdb5.3++-dev \ - curl cmake unzip libc6-dev gcc-multilib locales locales-all + curl cmake zip unzip libc6-dev gcc-multilib locales locales-all _fold_end } @@ -1115,6 +1145,11 @@ ci_export_vars() { echo "BUILD_VERSION=${IMAGE_VERSION}" >> "$GITHUB_ENV" echo "PATH=$HOME/.cargo/bin:$PATH" >> "$GITHUB_ENV" echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV" + if [[ "${TARGET}" == "x86_64-w64-mingw32" ]]; then + echo "PKG_TYPE=zip" >> "$GITHUB_ENV" + else + echo "PKG_TYPE=tar.gz" >> "$GITHUB_ENV" + fi fi }