diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bf1021e..fabcc8d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,6 +38,7 @@ jobs: id: set_toolchain run: | toolchain=$(grep channel rust-toolchain.toml | sed -r 's/channel = "(.*)"/\1/') + echo "using toolchain $toolchain" echo "toolchain=$toolchain" >> "$GITHUB_OUTPUT" if [[ $toolchain =~ ^nightly.* ]]; then echo "using nightly_toolchain $toolchain" diff --git a/.github/workflows/release-backend.yml b/.github/workflows/release-backend.yml index 4a92036..0476f88 100644 --- a/.github/workflows/release-backend.yml +++ b/.github/workflows/release-backend.yml @@ -1,4 +1,4 @@ -name: release-hello-tracing-backend +name: Release backend on: push: @@ -10,102 +10,32 @@ concurrency: cancel-in-progress: true jobs: - check: + toolchain: runs-on: ubuntu-latest + env: + nightly: ${{(github.event.inputs.nightly == 'true' || github.event_name == 'schedule') && 'true' || ''}} + outputs: + toolchain: ${{steps.set_toolchain.outputs.toolchain}} + nightly_toolchain: ${{steps.set_toolchain.outputs.nightly_toolchain}} steps: - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Install just - uses: taiki-e/install-action@v2 - with: - tool: just - - - name: Install protoc - uses: arduino/setup-protoc@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - uses: Swatinem/rust-cache@v2 - - - name: just check - run: just check - - fmt-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install Rust (nightly for fmt) - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - - - name: Install just - uses: taiki-e/install-action@v2 - with: - tool: just - - - uses: Swatinem/rust-cache@v2 - - - name: just fmt-check - run: just fmt-check - - lint: - runs-on: ubuntu-latest - needs: [check, fmt-check] - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - - name: Install just - uses: taiki-e/install-action@v2 - with: - tool: just - - - name: Install protoc - uses: arduino/setup-protoc@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - uses: Swatinem/rust-cache@v2 - - - name: just lint - run: just lint - - test: - runs-on: ubuntu-latest - needs: [check, fmt-check] - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Install just - uses: taiki-e/install-action@v2 - with: - tool: just - - - name: Install protoc - uses: arduino/setup-protoc@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - uses: Swatinem/rust-cache@v2 - - - name: just test - run: just test + - name: Set toolchain + id: set_toolchain + run: | + toolchain=$(grep channel rust-toolchain.toml | sed -r 's/channel = "(.*)"/\1/') + echo "using toolchain $toolchain" + echo "toolchain=$toolchain" >> "$GITHUB_OUTPUT" + if [[ $toolchain =~ ^nightly.* ]]; then + echo "using nightly_toolchain $toolchain" + echo "nightly_toolchain=$toolchain" >> "$GITHUB_OUTPUT" + else + echo "using nightly_toolchain nightly" + echo "nightly_toolchain=nightly" >> "$GITHUB_OUTPUT" + fi release: runs-on: ubuntu-latest - needs: [lint, test] + needs: [toolchain] steps: - name: Login to DockerHub uses: docker/login-action@v3 @@ -129,8 +59,9 @@ jobs: - name: Docker build and push hello-tracing-backend uses: docker/build-push-action@v6 with: + push: true file: hello-tracing-backend/Dockerfile + build-args: RUST_VERSION=${{needs.toolchain.outputs.toolchain}} platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - push: true diff --git a/.github/workflows/release-gateway.yml b/.github/workflows/release-gateway.yml index 6dddcbe..bf0dfe5 100644 --- a/.github/workflows/release-gateway.yml +++ b/.github/workflows/release-gateway.yml @@ -1,4 +1,4 @@ -name: release-hello-tracing-gateway +name: Release gateway on: push: @@ -10,102 +10,32 @@ concurrency: cancel-in-progress: true jobs: - check: + toolchain: runs-on: ubuntu-latest + env: + nightly: ${{(github.event.inputs.nightly == 'true' || github.event_name == 'schedule') && 'true' || ''}} + outputs: + toolchain: ${{steps.set_toolchain.outputs.toolchain}} + nightly_toolchain: ${{steps.set_toolchain.outputs.nightly_toolchain}} steps: - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Install just - uses: taiki-e/install-action@v2 - with: - tool: just - - - name: Install protoc - uses: arduino/setup-protoc@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - uses: Swatinem/rust-cache@v2 - - - name: just check - run: just check - - fmt-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Install Rust (nightly for fmt) - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - - - name: Install just - uses: taiki-e/install-action@v2 - with: - tool: just - - - uses: Swatinem/rust-cache@v2 - - - name: just fmt-check - run: just fmt-check - - lint: - runs-on: ubuntu-latest - needs: [check, fmt-check] - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - - name: Install just - uses: taiki-e/install-action@v2 - with: - tool: just - - - name: Install protoc - uses: arduino/setup-protoc@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - uses: Swatinem/rust-cache@v2 - - - name: just lint - run: just lint - - test: - runs-on: ubuntu-latest - needs: [check, fmt-check] - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Install just - uses: taiki-e/install-action@v2 - with: - tool: just - - - name: Install protoc - uses: arduino/setup-protoc@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - uses: Swatinem/rust-cache@v2 - - - name: just test - run: just test + - name: Set toolchain + id: set_toolchain + run: | + toolchain=$(grep channel rust-toolchain.toml | sed -r 's/channel = "(.*)"/\1/') + echo "using toolchain $toolchain" + echo "toolchain=$toolchain" >> "$GITHUB_OUTPUT" + if [[ $toolchain =~ ^nightly.* ]]; then + echo "using nightly_toolchain $toolchain" + echo "nightly_toolchain=$toolchain" >> "$GITHUB_OUTPUT" + else + echo "using nightly_toolchain nightly" + echo "nightly_toolchain=nightly" >> "$GITHUB_OUTPUT" + fi release: runs-on: ubuntu-latest - needs: [lint, test] + needs: [toolchain] steps: - name: Login to DockerHub uses: docker/login-action@v3 @@ -129,8 +59,9 @@ jobs: - name: Docker build and push hello-tracing-gateway uses: docker/build-push-action@v6 with: + push: true file: hello-tracing-gateway/Dockerfile + build-args: RUST_VERSION=${{needs.toolchain.outputs.toolchain}} platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - push: true