From 98a5d57fe89e3a92165a629aaa85b45b5a67ddc6 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 8 Oct 2021 00:40:08 -0400 Subject: [PATCH] Factor build steps into reusable workflow --- .github/workflows/build.yml | 34 ++++++++++++++++++++++++++++ .github/workflows/cargo-expand.yml | 23 +++---------------- .github/workflows/cargo-outdated.yml | 23 +++---------------- .github/workflows/cxxbridge-cmd.yml | 24 ++++---------------- 4 files changed, 44 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f734ec6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,34 @@ +name: build + +on: + workflow_call: + inputs: + crate: + required: true + type: string + bin: + required: false + type: string + +jobs: + build: + name: build ${{inputs.crate}} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: dtolnay/rust-toolchain@stable + - run: cargo install --force ${{inputs.crate}} --bin ${{inputs.bin || inputs.crate}} + - id: which + run: echo "::set-output name=which::$(which ${{inputs.bin || inputs.crate}})" + - run: echo "$PRIVATE_KEY" | gpg --import + env: + PRIVATE_KEY: ${{secrets.PRIVATE_KEY}} + - run: gpg --output ${{inputs.bin || inputs.crate}}.sig --detach-sig ${{steps.which.outputs.which}} + - run: gpg --output signing-key.gpg --dearmor signing-key.asc + - run: gpg --no-default-keyring --keyring ./signing-key.gpg --verify ${{inputs.bin || inputs.crate}}.sig ${{steps.which.outputs.which}} + - uses: softprops/action-gh-release@v1 + with: + files: | + ${{steps.which.outputs.which}} + ${{inputs.bin || inputs.crate}}.sig + fail_on_unmatched_files: true diff --git a/.github/workflows/cargo-expand.yml b/.github/workflows/cargo-expand.yml index adacdb8..88eebb2 100644 --- a/.github/workflows/cargo-expand.yml +++ b/.github/workflows/cargo-expand.yml @@ -7,23 +7,6 @@ on: jobs: build: - name: cargo-expand - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@stable - - run: cargo install --force cargo-expand - - id: which - run: echo "::set-output name=which::$(which cargo-expand)" - - run: echo "$PRIVATE_KEY" | gpg --import - env: - PRIVATE_KEY: ${{secrets.PRIVATE_KEY}} - - run: gpg --output cargo-expand.sig --detach-sig ${{steps.which.outputs.which}} - - run: gpg --output signing-key.gpg --dearmor signing-key.asc - - run: gpg --no-default-keyring --keyring ./signing-key.gpg --verify cargo-expand.sig ${{steps.which.outputs.which}} - - uses: softprops/action-gh-release@v1 - with: - files: | - ${{steps.which.outputs.which}} - cargo-expand.sig - fail_on_unmatched_files: true + uses: dtolnay/install/.github/workflows/build.yml@master + with: + crate: cargo-expand diff --git a/.github/workflows/cargo-outdated.yml b/.github/workflows/cargo-outdated.yml index aac5af0..c24455f 100644 --- a/.github/workflows/cargo-outdated.yml +++ b/.github/workflows/cargo-outdated.yml @@ -7,23 +7,6 @@ on: jobs: build: - name: cargo-outdated - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@stable - - run: cargo install --force cargo-outdated - - id: which - run: echo "::set-output name=which::$(which cargo-outdated)" - - run: echo "$PRIVATE_KEY" | gpg --import - env: - PRIVATE_KEY: ${{secrets.PRIVATE_KEY}} - - run: gpg --output cargo-outdated.sig --detach-sig ${{steps.which.outputs.which}} - - run: gpg --output signing-key.gpg --dearmor signing-key.asc - - run: gpg --no-default-keyring --keyring ./signing-key.gpg --verify cargo-outdated.sig ${{steps.which.outputs.which}} - - uses: softprops/action-gh-release@v1 - with: - files: | - ${{steps.which.outputs.which}} - cargo-outdated.sig - fail_on_unmatched_files: true + uses: dtolnay/install/.github/workflows/build.yml@master + with: + crate: cargo-outdated diff --git a/.github/workflows/cxxbridge-cmd.yml b/.github/workflows/cxxbridge-cmd.yml index f396b36..60c4d77 100644 --- a/.github/workflows/cxxbridge-cmd.yml +++ b/.github/workflows/cxxbridge-cmd.yml @@ -7,23 +7,7 @@ on: jobs: build: - name: cxxbridge-cmd - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@stable - - run: cargo install --force cxxbridge-cmd - - id: which - run: echo "::set-output name=which::$(which cxxbridge)" - - run: echo "$PRIVATE_KEY" | gpg --import - env: - PRIVATE_KEY: ${{secrets.PRIVATE_KEY}} - - run: gpg --output cxxbridge.sig --detach-sig ${{steps.which.outputs.which}} - - run: gpg --output signing-key.gpg --dearmor signing-key.asc - - run: gpg --no-default-keyring --keyring ./signing-key.gpg --verify cxxbridge.sig ${{steps.which.outputs.which}} - - uses: softprops/action-gh-release@v1 - with: - files: | - ${{steps.which.outputs.which}} - cxxbridge.sig - fail_on_unmatched_files: true + uses: dtolnay/install/.github/workflows/build.yml@master + with: + crate: cxxbridge-cmd + bin: cxxbridge