diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0d6b55cfa..ce69fadda 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,18 +1,6 @@ name: Release -# READ THIS FIRST -# -# This process is by no means perfect, but it currently achieves our goals -# -# There's some magic in the `Check version match` step for each job, -# but it's there's a reason — i.e. GHA sucks — and we want to only build the package for the respective tag -# this allows us to perform individual releases instead of launching them all one by one. -# -# Now, on to the magic: -# 1 - Start by fetching the workspace metadata -# 2 - Using `jq`, get the package name and version -# and then format them into a string that should match the tag -# 4 - If it does not match the tag, fail the build +# NOTE(@jmg-duarte,25/11/24): wasm may not be needed in all places but as of now, this works on: push: @@ -25,13 +13,9 @@ concurrency: cancel-in-progress: true jobs: - build_and_release_mater_cli: + mater_cli_check_version: runs-on: self-hosted - permissions: - contents: write - packages: write - if: github.ref_type == 'tag' && startsWith(github.ref_name, 'mater-cli-v') steps: @@ -51,14 +35,73 @@ jobs: exit 1; fi - # make the version available as a "checked" output in later steps echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT" - - id: build-release - name: Build in release mode + outputs: + package-version: ${{ steps.check-version.outputs.PACKAGE_VERSION }} + + mater_cli_build_linux: + runs-on: self-hosted + + needs: + - mater_cli_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Build in release mode run: | RUSTFLAGS="-D warnings" cargo build --release --locked --package mater-cli - echo "PACKAGE_SHA256=$(sha256sum target/release/mater-cli | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + + - uses: actions/upload-artifact@v4 + with: + name: mater-cli-linux-x64 + path: target/release/mater-cli + retention-days: 1 + + mater_cli_build_macos: + runs-on: + - macos-latest + + strategy: + matrix: + include: + - target: x86_64-apple-darwin + arch: x64 + - target: aarch64-apple-darwin + arch: arm64 + + needs: + - mater_cli_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - uses: dtolnay/rust-toolchain@1.81.0 + with: + targets: wasm32-unknown-unknown,${{ matrix.target }} + + - name: Build in release mode + run: | + RUSTFLAGS="-D warnings" cargo build --release --locked --package mater-cli --target ${{ matrix.target }} + + - uses: actions/upload-artifact@v4 + with: + name: mater-cli-macos-${{ matrix.arch }} + path: target/${{ matrix.target }}/release/mater-cli + retention-days: 1 + + mater_cli_build_docker: + runs-on: self-hosted + + needs: + - mater_cli_check_version + + permissions: + packages: write + + steps: + - uses: actions/checkout@v4.2.2 - name: Login to Github Container Registry uses: docker/login-action@v3 @@ -72,33 +115,71 @@ jobs: docker build \ --build-arg VCS_REF="$(git rev-parse HEAD)" \ --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ - --tag ghcr.io/eigerco/mater-cli:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" \ + --tag ghcr.io/eigerco/mater-cli:"${{ needs.mater_cli_check_version.outputs.package-version }}" \ --file ./docker/dockerfiles/mater-cli.Dockerfile \ . - docker push ghcr.io/eigerco/mater-cli:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" + docker push ghcr.io/eigerco/mater-cli:"${{ needs.mater_cli_check_version.outputs.package-version }}" + + mater_cli_release: + needs: + - mater_cli_check_version + - mater_cli_build_linux + - mater_cli_build_macos + - mater_cli_build_docker + + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - id: download-artifacts + uses: actions/download-artifact@v4 + + - name: Prepare folder + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + + mv mater-cli-linux-x64/mater-cli ./ + rmdir mater-cli-linux-x64 + mv mater-cli mater-cli-linux-x64 + + mv mater-cli-macos-x64/mater-cli ./ + rmdir mater-cli-macos-x64 + mv mater-cli mater-cli-macos-x64 + + mv mater-cli-macos-arm64/mater-cli ./ + rmdir mater-cli-macos-arm64 + mv mater-cli mater-cli-macos-arm64 + + - name: Calculate SHA256 + id: calculate-sha256 + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + echo "LINUX_X64_SHA256=$(sha256sum mater-cli-linux-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_X64_SHA256=$(sha256sum mater-cli-macos-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_ARM64_SHA256=$(sha256sum mater-cli-macos-arm64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" - name: Perform release uses: softprops/action-gh-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # set github token for rw rights on repo with: - tag_name: ${{ github.ref_name }} # set the name of the release the tag + tag_name: ${{ github.ref_name }} body: | - Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/mater-cli/?tag=${{ steps.check-version.outputs.PACKAGE_VERSION }} + Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/mater-cli?tag=${{ needs.mater_cli_check_version.outputs.package-version }} + + | Binary | SHA256 | + | ----------------------- | ---------------------------------------------------------- | + | `mater-cli-linux-x64` | `${{ steps.calculate-sha256.outputs.LINUX_X64_SHA256 }}` | + | `mater-cli-macos-x64` | `${{ steps.calculate-sha256.outputs.MACOS_X64_SHA256 }}` | + | `mater-cli-macos-arm64` | `${{ steps.calculate-sha256.outputs.MACOS_ARM64_SHA256 }}` | - | Binary | SHA256 | - | ------------------------ | --------------------------------------------------- | - | `${{ github.ref_name }}` | `${{ steps.build-release.outputs.PACKAGE_SHA256 }}` | files: | - target/release/mater-cli + ${{ steps.download-artifacts.outputs.download-path }}/mater-cli-* - build_and_release_storagext_cli: + storagext_cli_check_version: runs-on: self-hosted - permissions: - contents: write - packages: write - if: github.ref_type == 'tag' && startsWith(github.ref_name, 'storagext-cli-v') steps: @@ -118,14 +199,75 @@ jobs: exit 1; fi - # make the version available as a "checked" output in later steps echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT" - - id: build-release - name: Build in release mode + outputs: + package-version: ${{ steps.check-version.outputs.PACKAGE_VERSION }} + + storagext_cli_build_linux: + runs-on: self-hosted + + needs: + - storagext_cli_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Build in release mode run: | RUSTFLAGS="-D warnings" cargo build --release --locked --package storagext-cli - echo "PACKAGE_SHA256=$(sha256sum target/release/storagext-cli | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + + - uses: actions/upload-artifact@v4 + with: + name: storagext-cli-linux-x64 + path: target/release/storagext-cli + retention-days: 1 + + storagext_cli_build_macos: + runs-on: + - macos-latest + + strategy: + matrix: + include: + - target: x86_64-apple-darwin + arch: x64 + - target: aarch64-apple-darwin + arch: arm64 + + needs: + - storagext_cli_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - uses: dtolnay/rust-toolchain@1.81.0 + with: + targets: wasm32-unknown-unknown,${{ matrix.target }} + + - name: Build in release mode + run: | + RUSTFLAGS="-D warnings" cargo build --release --locked --package storagext-cli --target ${{ matrix.target }} + + - uses: actions/upload-artifact@v4 + with: + name: storagext-cli-macos-${{ runner.arch }} + path: target/release/storagext-cli + retention-days: 1 + + storagext_cli_build_docker: + runs-on: self-hosted + + needs: + - storagext_cli_check_version + + permissions: + packages: write + + if: github.ref_type == 'tag' && startsWith(github.ref_name, 'storagext-cli-v') + + steps: + - uses: actions/checkout@v4.2.2 - name: Login to Github Container Registry uses: docker/login-action@v3 @@ -139,33 +281,71 @@ jobs: docker build \ --build-arg VCS_REF="$(git rev-parse HEAD)" \ --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ - --tag ghcr.io/eigerco/storagext-cli:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" \ + --tag ghcr.io/eigerco/storagext-cli:"${{ needs.storagext_cli_check_version.outputs.package-version }}" \ --file ./docker/dockerfiles/storagext-cli.Dockerfile \ . - docker push ghcr.io/eigerco/storagext-cli:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" + docker push ghcr.io/eigerco/storagext-cli:"${{ needs.storagext_cli_check_version.outputs.package-version }}" + + storagext_cli_release: + needs: + - storagext_cli_check_version + - storagext_cli_build_linux + - storagext_cli_build_macos + - storagext_cli_build_docker + + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - id: download-artifacts + uses: actions/download-artifact@v4 + + - name: Prepare folder + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + + mv storagext-cli-linux-x64/storagext-cli ./ + rmdir storagext-cli-linux-x64 + mv storagext-cli storagext-cli-linux-x64 + + mv storagext-cli-macos-x64/storagext-cli ./ + rmdir storagext-cli-macos-x64 + mv storagext-cli storagext-cli-macos-x64 + + mv storagext-cli-macos-arm64/storagext-cli ./ + rmdir storagext-cli-macos-arm64 + mv storagext-cli storagext-cli-macos-arm64 + + - name: Calculate SHA256 + id: calculate-sha256 + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + echo "LINUX_X64_SHA256=$(sha256sum storagext-cli-linux-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_X64_SHA256=$(sha256sum storagext-cli-macos-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_ARM64_SHA256=$(sha256sum storagext-cli-macos-arm64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" - name: Perform release uses: softprops/action-gh-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # set github token for rw rights on repo with: - tag_name: ${{ github.ref_name }} # set the name of the release the tag + tag_name: ${{ github.ref_name }} body: | - Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/storagext-cli/?tag=${{ steps.check-version.outputs.PACKAGE_VERSION }} + Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/storagext-cli?tag=${{ needs.storagext_cli_check_version.outputs.package-version }} + + | Binary | SHA256 | + | --------------------------- | -------------------------------------------------------------------- | + | `storagext-cli-linux-x64` | `${{ steps.calculate-sha256.outputs.LINUX_x64_SHA256 }}` | + | `storagext-cli-macos-x64` | `${{ steps.calculate-sha256.outputs.MACOS_x64_SHA256 }}` | + | `storagext-cli-macos-arm64` | `${{ steps.calculate-sha256.outputs.MACOS_ARM64_SHA256 }}` | - | Binary | SHA256 | - | ------------------------ | --------------------------------------------------- | - | `${{ github.ref_name }}` | `${{ steps.build-release.outputs.PACKAGE_SHA256 }}` | files: | - target/release/storagext-cli + ${{steps.download-artifacts.outputs.download-path}}/storagext-cli-* - build_and_release_polka_storage_node: + polka_storage_node_check_version: runs-on: self-hosted - permissions: - contents: write - packages: write - if: github.ref_type == 'tag' && startsWith(github.ref_name, 'polka-storage-node-v') steps: @@ -185,14 +365,73 @@ jobs: exit 1; fi - # make the version available as a "checked" output in later steps echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT" - - id: build-release - name: Build in release mode + outputs: + package-version: ${{ steps.check-version.outputs.PACKAGE_VERSION }} + + polka_storage_node_build_linux: + runs-on: self-hosted + + needs: + - polka_storage_node_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Build in release mode run: | RUSTFLAGS="-D warnings" cargo build --release --locked --package polka-storage-node --features polka-storage-runtime/testnet - echo "PACKAGE_SHA256=$(sha256sum target/release/polka-storage-node | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + + - uses: actions/upload-artifact@v4 + with: + name: polka-storage-node-linux-x64 + path: target/release/polka-storage-node + retention-days: 1 + + polka_storage_node_build_macos: + runs-on: + - macos-latest + + strategy: + matrix: + include: + - target: x86_64-apple-darwin + arch: x64 + - target: aarch64-apple-darwin + arch: arm64 + + needs: + - polka_storage_node_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - uses: dtolnay/rust-toolchain@1.81.0 + with: + targets: wasm32-unknown-unknown,${{ matrix.target }} + + - name: Build in release mode + run: | + RUSTFLAGS="-D warnings" cargo build --release --locked --package polka-storage-node --target ${{ matrix.target }} + + - uses: actions/upload-artifact@v4 + with: + name: polka-storage-node-macos-${{ runner.arch }} + path: target/release/polka-storage-node + retention-days: 1 + + polka_storage_node_build_docker: + runs-on: self-hosted + + needs: + - polka_storage_node_check_version + + permissions: + packages: write + + steps: + - uses: actions/checkout@v4.2.2 - name: Login to Github Container Registry uses: docker/login-action@v3 @@ -206,34 +445,72 @@ jobs: docker build \ --build-arg VCS_REF="$(git rev-parse HEAD)" \ --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ - --tag ghcr.io/eigerco/polka-storage-node:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" \ + --tag ghcr.io/eigerco/polka-storage-node:"${{ needs.polka_storage_node_check_version.outputs.package-version }}" \ --file ./docker/dockerfiles/polka-storage-node.Dockerfile \ . - docker push ghcr.io/eigerco/polka-storage-node:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" + docker push ghcr.io/eigerco/polka-storage-node:"${{ needs.polka_storage_node_check_version.outputs.package-version }}" + + polka_storage_node_release: + needs: + - polka_storage_node_check_version + - polka_storage_node_build_linux + - polka_storage_node_build_macos + - polka_storage_node_build_docker + + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - id: download-artifacts + uses: actions/download-artifact@v4 + + - name: Prepare folder + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + + mv polka-storage-node-linux-x64/polka-storage-node ./ + rmdir polka-storage-node-linux-x64 + mv polka-storage-node polka-storage-node-linux-x64 + + mv polka-storage-node-macos-x64/polka-storage-node ./ + rmdir polka-storage-node-macos-x64 + mv polka-storage-node polka-storage-node-macos-x64 + + mv polka-storage-node-macos-arm64/polka-storage-node ./ + rmdir polka-storage-node-macos-arm64 + mv polka-storage-node polka-storage-node-macos-arm64 + + - name: Calculate SHA256 + id: calculate-sha256 + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + echo "LINUX_X64_SHA256=$(sha256sum polka-storage-node-linux-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_X64_SHA256=$(sha256sum polka-storage-node-macos-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_ARM64_SHA256=$(sha256sum polka-storage-node-macos-arm64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" - name: Perform release uses: softprops/action-gh-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # set github token for rw rights on repo with: - tag_name: ${{ github.ref_name }} # set the name of the release the tag + tag_name: ${{ github.ref_name }} body: | - Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/polka-storage-node/?tag=${{ steps.check-version.outputs.PACKAGE_VERSION }} + Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/polka-storage-node?tag=${{ needs.polka_storage_node_check_version.outputs.package-version }} + + | Binary | SHA256 | + | -------------------------------- | ---------------------------------------------------------- | + | `polka-storage-node-linux-x64` | `${{ steps.calculate-sha256.outputs.LINUX_x64_SHA256 }}` | + | `polka-storage-node-macos-x64` | `${{ steps.calculate-sha256.outputs.MACOS_x64_SHA256 }}` | + | `polka-storage-node-macos-arm64` | `${{ steps.calculate-sha256.outputs.MACOS_ARM64_SHA256 }}` | - | Binary | SHA256 | - | ------------------------ | --------------------------------------------------- | - | `${{ github.ref_name }}` | `${{ steps.build-release.outputs.PACKAGE_SHA256 }}` | files: | - target/release/polka-storage-node + ${{steps.download-artifacts.outputs.download-path}}/polka-storage-node-* - build_and_release_polka_storage_provider_server: + polka_storage_provider_client_check_version: runs-on: self-hosted - permissions: - contents: write - packages: write - - if: github.ref_type == 'tag' && startsWith(github.ref_name, 'polka-storage-provider-server-v') + if: github.ref_type == 'tag' && startsWith(github.ref_name, 'polka-storage-provider-client-v') steps: - uses: actions/checkout@v4.2.2 @@ -243,23 +520,82 @@ jobs: run: | # used later in the build for docker tagging PACKAGE_VERSION="$(cargo metadata --no-deps --color never --format-version 1 --locked | - jq -r '.packages[] | select(.name == "polka-storage-provider-server") | .version')" + jq -r '.packages[] | select(.name == "polka-storage-provider-client") | .version')" # used for checking the tag - PACKAGE_VERSION_WITH_NAME=$(echo "polka-storage-provider-server-v$PACKAGE_VERSION") + PACKAGE_VERSION_WITH_NAME=$(echo "polka-storage-provider-client-v$PACKAGE_VERSION") if [[ "$PACKAGE_VERSION_WITH_NAME" != "$GITHUB_REF_NAME" ]]; then exit 1; fi - # make the version available as a "checked" output in later steps echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT" - - id: build-release - name: Build in release mode + outputs: + package-version: ${{ steps.check-version.outputs.PACKAGE_VERSION }} + + polka_storage_provider_client_build_linux: + runs-on: self-hosted + + needs: + - polka_storage_provider_client_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Build in release mode run: | - RUSTFLAGS="-D warnings" cargo build --release --locked --package polka-storage-provider-server - echo "PACKAGE_SHA256=$(sha256sum target/release/polka-storage-provider-server | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + RUSTFLAGS="-D warnings" cargo build --release --locked --package polka-storage-provider-client + + - uses: actions/upload-artifact@v4 + with: + name: polka-storage-provider-client-linux-x64 + path: target/release/polka-storage-provider-client + retention-days: 1 + + polka_storage_provider_client_build_macos: + runs-on: + - macos-latest + + strategy: + matrix: + include: + - target: x86_64-apple-darwin + arch: x64 + - target: aarch64-apple-darwin + arch: arm64 + + needs: + - polka_storage_provider_client_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - uses: dtolnay/rust-toolchain@1.81.0 + with: + targets: wasm32-unknown-unknown,${{ matrix.target }} + + - name: Build in release mode + run: | + RUSTFLAGS="-D warnings" cargo build --release --locked --package polka-storage-provider-client --target ${{ matrix.target }} + + - uses: actions/upload-artifact@v4 + with: + name: polka-storage-provider-client-macos-${{ runner.arch }} + path: target/release/polka-storage-provider-client + retention-days: 1 + + polka_storage_provider_client_build_docker: + runs-on: self-hosted + + needs: + - polka_storage_provider_client_check_version + + permissions: + packages: write + + steps: + - uses: actions/checkout@v4.2.2 - name: Login to Github Container Registry uses: docker/login-action@v3 @@ -273,34 +609,72 @@ jobs: docker build \ --build-arg VCS_REF="$(git rev-parse HEAD)" \ --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ - --tag ghcr.io/eigerco/polka-storage-provider-server:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" \ - --file ./docker/dockerfiles/polka-storage-provider-server.Dockerfile \ + --tag ghcr.io/eigerco/polka-storage-provider-client:"${{ needs.polka_storage_provider_client_check_version.outputs.package-version }}" \ + --file ./docker/dockerfiles/polka-storage-provider-client.Dockerfile \ . - docker push ghcr.io/eigerco/polka-storage-provider-server:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" + docker push ghcr.io/eigerco/polka-storage-provider-client:"${{ needs.polka_storage_provider_client_check_version.outputs.package-version }}" + + polka_storage_provider_client_release: + needs: + - polka_storage_provider_client_check_version + - polka_storage_provider_client_build_linux + - polka_storage_provider_client_build_macos + - polka_storage_provider_client_build_docker + + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - id: download-artifacts + uses: actions/download-artifact@v4 + + - name: Prepare folder + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + + mv polka-storage-provider-client-linux-x64/polka-storage-provider-client ./ + rmdir polka-storage-provider-client-linux-x64 + mv polka-storage-provider-client polka-storage-provider-client-linux-x64 + + mv polka-storage-provider-client-macos-x64/polka-storage-provider-client ./ + rmdir polka-storage-provider-client-macos-x64 + mv polka-storage-provider-client polka-storage-provider-client-macos-x64 + + mv polka-storage-provider-client-macos-arm64/polka-storage-provider-client ./ + rmdir polka-storage-provider-client-macos-arm64 + mv polka-storage-provider-client polka-storage-provider-client-macos-arm64 + + - name: Calculate SHA256 + id: calculate-sha256 + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + echo "LINUX_X64_SHA256=$(sha256sum polka-storage-provider-client-linux-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_X64_SHA256=$(sha256sum polka-storage-provider-client-macos-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_ARM64_SHA256=$(sha256sum polka-storage-provider-client-macos-arm64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" - name: Perform release uses: softprops/action-gh-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # set github token for rw rights on repo with: - tag_name: ${{ github.ref_name }} # set the name of the release the tag + tag_name: ${{ github.ref_name }} body: | - Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/polka-storage-provider-server/?tag=${{ steps.check-version.outputs.PACKAGE_VERSION }} + Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/polka-storage-provider-client?tag=${{ needs.polka_storage_provider_client_check_version.outputs.package-version }} + + | Binary | SHA256 | + | ------------------------------------------- | ---------------------------------------------------------- | + | `polka-storage-provider-client-linux-x64` | `${{ steps.calculate-sha256.outputs.LINUX_x64_SHA256 }}` | + | `polka-storage-provider-client-macos-x64` | `${{ steps.calculate-sha256.outputs.MACOS_x64_SHA256 }}` | + | `polka-storage-provider-client-macos-arm64` | `${{ steps.calculate-sha256.outputs.MACOS_ARM64_SHA256 }}` | - | Binary | SHA256 | - | ------------------------ | --------------------------------------------------- | - | `${{ github.ref_name }}` | `${{ steps.build-release.outputs.PACKAGE_SHA256 }}` | files: | - target/release/polka-storage-provider-server + ${{steps.download-artifacts.outputs.download-path}}/polka-storage-provider-client-* - build_and_release_polka_storage_provider_client: + polka_storage_provider_server_check_version: runs-on: self-hosted - permissions: - contents: write - packages: write - - if: github.ref_type == 'tag' && startsWith(github.ref_name, 'polka-storage-provider-client-v') + if: github.ref_type == 'tag' && startsWith(github.ref_name, 'polka-storage-provider-server-v') steps: - uses: actions/checkout@v4.2.2 @@ -310,23 +684,82 @@ jobs: run: | # used later in the build for docker tagging PACKAGE_VERSION="$(cargo metadata --no-deps --color never --format-version 1 --locked | - jq -r '.packages[] | select(.name == "polka-storage-provider-client") | .version')" + jq -r '.packages[] | select(.name == "polka-storage-provider-server") | .version')" # used for checking the tag - PACKAGE_VERSION_WITH_NAME=$(echo "polka-storage-provider-client-v$PACKAGE_VERSION") + PACKAGE_VERSION_WITH_NAME=$(echo "polka-storage-provider-server-v$PACKAGE_VERSION") if [[ "$PACKAGE_VERSION_WITH_NAME" != "$GITHUB_REF_NAME" ]]; then exit 1; fi - # make the version available as a "checked" output in later steps echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT" - - id: build-release - name: Build in release mode + outputs: + package-version: ${{ steps.check-version.outputs.PACKAGE_VERSION }} + + polka_storage_provider_server_build_linux: + runs-on: self-hosted + + needs: + - polka_storage_provider_server_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Build in release mode run: | - RUSTFLAGS="-D warnings" cargo build --release --locked --package polka-storage-provider-client - echo "PACKAGE_SHA256=$(sha256sum target/release/polka-storage-provider-client | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + RUSTFLAGS="-D warnings" cargo build --release --locked --package polka-storage-provider-server + + - uses: actions/upload-artifact@v4 + with: + name: polka-storage-provider-server-linux-x64 + path: target/release/polka-storage-provider-server + retention-days: 1 + + polka_storage_provider_server_build_macos: + runs-on: + - macos-latest + + strategy: + matrix: + include: + - target: x86_64-apple-darwin + arch: x64 + - target: aarch64-apple-darwin + arch: arm64 + + needs: + - polka_storage_provider_server_check_version + + steps: + - uses: actions/checkout@v4.2.2 + + - uses: dtolnay/rust-toolchain@1.81.0 + with: + targets: wasm32-unknown-unknown + + - name: Build in release mode + run: | + RUSTFLAGS="-D warnings" cargo build --release --locked --package polka-storage-provider-server --target ${{ matrix.target }} + + - uses: actions/upload-artifact@v4 + with: + name: polka-storage-provider-server-macos-${{ runner.arch }} + path: target/release/polka-storage-provider-server + retention-days: 1 + + polka_storage_provider_server_build_docker: + runs-on: self-hosted + + needs: + - polka_storage_provider_server_check_version + + permissions: + packages: write + + steps: + - uses: actions/checkout@v4.2.2 - name: Login to Github Container Registry uses: docker/login-action@v3 @@ -340,22 +773,64 @@ jobs: docker build \ --build-arg VCS_REF="$(git rev-parse HEAD)" \ --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ - --tag ghcr.io/eigerco/polka-storage-provider-client:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" \ - --file ./docker/dockerfiles/polka-storage-provider-client.Dockerfile \ + --tag ghcr.io/eigerco/polka-storage-provider-server:"${{ needs.polka_storage_provider_server_check_version.outputs.package-version }}" \ + --file ./docker/dockerfiles/polka-storage-provider-server.Dockerfile \ . - docker push ghcr.io/eigerco/polka-storage-provider-client:"${{ steps.check-version.outputs.PACKAGE_VERSION }}" + docker push ghcr.io/eigerco/polka-storage-provider-server:"${{ needs.polka_storage_provider_server_check_version.outputs.package-version }}" + + polka_storage_provider_server_release: + needs: + - polka_storage_provider_server_check_version + - polka_storage_provider_server_build_linux + - polka_storage_provider_server_build_macos + - polka_storage_provider_server_build_docker + + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - id: download-artifacts + uses: actions/download-artifact@v4 + + - name: Prepare folder + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + + mv polka-storage-provider-server-linux-x64/polka-storage-provider-server ./ + rmdir polka-storage-provider-server-linux-x64 + mv polka-storage-provider-server polka-storage-provider-server-linux-x64 + + mv polka-storage-provider-server-macos-x64/polka-storage-provider-server ./ + rmdir polka-storage-provider-server-macos-x64 + mv polka-storage-provider-server polka-storage-provider-server-macos-x64 + + mv polka-storage-provider-server-macos-arm64/polka-storage-provider-server ./ + rmdir polka-storage-provider-server-macos-arm64 + mv polka-storage-provider-server polka-storage-provider-server-macos-arm64 + + - name: Calculate SHA256 + id: calculate-sha256 + run: | + cd ${{ steps.download-artifacts.outputs.download-path }} + echo "LINUX_X64_SHA256=$(sha256sum polka-storage-provider-server-linux-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_X64_SHA256=$(sha256sum polka-storage-provider-server-macos-x64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" + echo "MACOS_ARM64_SHA256=$(sha256sum polka-storage-provider-server-macos-arm64 | sed 's/\(.*\) .*/\1/')" >> "$GITHUB_OUTPUT" - name: Perform release uses: softprops/action-gh-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # set github token for rw rights on repo with: - tag_name: ${{ github.ref_name }} # set the name of the release the tag + tag_name: ${{ github.ref_name }} body: | - Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/polka-storage-provider-client/?tag=${{ steps.check-version.outputs.PACKAGE_VERSION }} + Docker container release: https://github.com/eigerco/polka-storage/pkgs/container/polka-storage-provider-server?tag=${{ needs.polka_storage_provider_server_check_version.outputs.package-version }} + + | Binary | SHA256 | + | ------------------------------------------- | ---------------------------------------------------------- | + | `polka-storage-provider-server-linux-x64` | `${{ steps.calculate-sha256.outputs.LINUX_x64_SHA256 }}` | + | `polka-storage-provider-server-macos-x64` | `${{ steps.calculate-sha256.outputs.MACOS_x64_SHA256 }}` | + | `polka-storage-provider-server-macos-arm64` | `${{ steps.calculate-sha256.outputs.MACOS_ARM64_SHA256 }}` | - | Binary | SHA256 | - | ------------------------ | --------------------------------------------------- | - | `${{ github.ref_name }}` | `${{ steps.build-release.outputs.PACKAGE_SHA256 }}` | files: | - target/release/polka-storage-provider-client + ${{steps.download-artifacts.outputs.download-path}}/polka-storage-provider-server-* diff --git a/Cargo.lock b/Cargo.lock index 12b2ab088..aafa54bce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8024,7 +8024,7 @@ dependencies = [ [[package]] name = "mater-cli" -version = "0.1.0" +version = "0.1.0-t" dependencies = [ "anyhow", "clap", diff --git a/storage/mater-cli/Cargo.toml b/storage/mater-cli/Cargo.toml index 420759edd..5fea16469 100644 --- a/storage/mater-cli/Cargo.toml +++ b/storage/mater-cli/Cargo.toml @@ -5,7 +5,7 @@ homepage.workspace = true license-file.workspace = true name = "mater-cli" repository.workspace = true -version = "0.1.0" +version = "0.1.0-t" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html