Auto merge! (merge-pr-in-all) #267
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| paths: | |
| - 'Dockerfile' | |
| - 'src/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - '.github/workflows/ci.yml' | |
| push: | |
| branches: | |
| - 'master' | |
| tags: | |
| - v* | |
| env: | |
| CARGO_INCREMENTAL: 0 | |
| RUST_CACHE_VERSION: v1 | |
| REGISTRY_IMAGE: ghcr.io/eewbot/webhook-sender | |
| PROJ_NAME: webhook-sender | |
| jobs: | |
| release_linux: | |
| if: ${{ github.event_name != 'pull_request' }} | |
| continue-on-error: false | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - ghimage: ubuntu-24.04 | |
| os: linux | |
| arch: x86_64 | |
| target: x86_64-unknown-linux-gnu | |
| output: webhook-sender | |
| - ghimage: ubuntu-24.04-arm | |
| os: linux | |
| arch: aarch64 | |
| target: aarch64-unknown-linux-gnu | |
| output: webhook-sender | |
| - ghimage: ubuntu-24.04 | |
| os: windows | |
| arch: x86_64 | |
| target: x86_64-pc-windows-gnu | |
| output: webhook-sender.exe | |
| permissions: | |
| contents: write | |
| runs-on: ${{ matrix.ghimage }} | |
| steps: | |
| - uses: actions/checkout@v6.0.1 | |
| with: | |
| submodules: true | |
| - if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }} | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y gcc-mingw-w64-x86-64 | |
| rustup target add x86_64-pc-windows-gnu | |
| - name: Install cargo license | |
| run: | | |
| cargo install cargo-license | |
| - uses: Swatinem/rust-cache@v2.8.2 | |
| with: | |
| prefix-key: ${{ env.RUST_CACHE_VERSION }}-rust | |
| - name: Build | |
| env: | |
| TARGET: ${{ matrix.target }} | |
| run: | | |
| cargo build --release --target $TARGET | |
| - name: Create CREDITS file | |
| env: | |
| TARGET: ${{ matrix.target }} | |
| run: | | |
| cargo license \ | |
| --authors \ | |
| --do-not-bundle \ | |
| --avoid-dev-deps \ | |
| --filter-platform $TARGET \ | |
| > CREDITS | |
| - name: Make release file | |
| env: | |
| TARGET: ${{ matrix.target }} | |
| OUTPUT: ${{ matrix.output }} | |
| run: | | |
| DIR_NAME="${{ env.PROJ_NAME }}-${{ matrix.os }}-${{ matrix.arch }}-${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || format('master-{0}', github.sha) }}" | |
| mkdir "$DIR_NAME" | |
| cp ./target/$TARGET/release/$OUTPUT "$DIR_NAME/" | |
| cp ./LICENSE "$DIR_NAME/" | |
| cp ./CREDITS "$DIR_NAME/" | |
| cp ./README.md "$DIR_NAME/" | |
| tar cvf "$DIR_NAME.tar.gz" "$DIR_NAME/" | |
| - name: pre-release | |
| uses: softprops/action-gh-release@v2.5.0 | |
| if: "! startsWith(github.ref, 'refs/tags/')" | |
| with: | |
| tag_name: master-${{ github.sha }} | |
| prerelease: true | |
| fail_on_unmatched_files: true | |
| files: | | |
| *.tar.gz | |
| - name: tagged-release | |
| uses: softprops/action-gh-release@v2.5.0 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| fail_on_unmatched_files: true | |
| files: | | |
| *.tar.gz | |
| clippy_and_test: | |
| continue-on-error: false | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - ghimage: ubuntu-24.04 | |
| dockerarch: linux/amd64 | |
| mcarch: amd64 | |
| - ghimage: ubuntu-24.04-arm | |
| dockerarch: linux/arm64 | |
| mcarch: arm64 | |
| permissions: | |
| packages: write | |
| checks: write | |
| contents: read | |
| deployments: write | |
| runs-on: ${{ matrix.ghimage }} | |
| steps: | |
| - uses: actions/checkout@v6.0.1 | |
| - name: Get Rust toolchain | |
| id: toolchain | |
| run: | | |
| awk -F'[ ="]+' '$1 == "channel" { print "toolchain=" $2 }' rust-toolchain >> "$GITHUB_OUTPUT" | |
| - name: install clippy | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: ${{ steps.toolchain.outputs.toolchain }} | |
| components: clippy | |
| - name: cache dependencies | |
| uses: Swatinem/rust-cache@v2.8.2 | |
| with: | |
| prefix-key: ${{ env.RUST_CACHE_VERSION }}-rust | |
| - name: clippy check | |
| uses: yanorei32/action-clippy@50412b135153ebee7d4b8a5b868c4defdc663683 | |
| with: | |
| reporter: github-check | |
| - name: unit test | |
| run: | | |
| cargo test --no-run --locked | |
| cargo test | |
| - name: release build | |
| run: cargo build --release | |
| docker_build: | |
| continue-on-error: false | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - ghimage: ubuntu-24.04 | |
| dockerarch: linux/amd64 | |
| mcarch: amd64 | |
| - ghimage: ubuntu-24.04-arm | |
| dockerarch: linux/arm64 | |
| mcarch: arm64 | |
| permissions: | |
| packages: write | |
| checks: write | |
| contents: read | |
| deployments: write | |
| runs-on: ${{ matrix.ghimage }} | |
| steps: | |
| - uses: actions/checkout@v6.0.1 | |
| - uses: docker/metadata-action@v5.10.0 | |
| id: meta | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=sha | |
| - uses: docker/setup-buildx-action@v3.12.0 | |
| - uses: docker/login-action@v3.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and Push | |
| uses: docker/build-push-action@v6.18.0 | |
| id: build | |
| with: | |
| context: . | |
| platforms: ${{ matrix.dockerimage }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Export Digest | |
| if: ${{ github.event_name != 'pull_request' }} | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - uses: actions/upload-artifact@v6.0.0 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| with: | |
| name: digests-${{ matrix.mcarch }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| docker_merge: | |
| runs-on: ubuntu-24.04 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| permissions: | |
| packages: write | |
| checks: write | |
| contents: read | |
| deployments: write | |
| needs: | |
| - docker_build | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v7.0.0 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-* | |
| merge-multiple: true | |
| - uses: docker/setup-buildx-action@v3.12.0 | |
| - uses: docker/metadata-action@v5.10.0 | |
| id: meta | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| - uses: docker/login-action@v3.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create manifest list and push | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |