diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dcdb9b5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,110 @@ +name: Publish release binaries + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + test: + description: 'Testing the release workflow' + required: true + default: 'true' + +jobs: + build: + name: Publish for ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + name: [linux, armv7, arm64, windows, macos] + include: + - name: linux + os: ubuntu-latest + build_deps: > + libpcsclite-dev + archive_name: age-plugin-yubikey.tar.gz + asset_suffix: x86_64-linux.tar.gz + + - name: armv7 + os: ubuntu-latest + target: armv7-unknown-linux-gnueabihf + build_deps: > + gcc-arm-linux-gnueabihf + cargo_config: | + [target.armv7-unknown-linux-gnueabihf] + linker = "arm-linux-gnueabihf-gcc" + build_flags: --target armv7-unknown-linux-gnueabihf + archive_name: age-plugin-yubikey.tar.gz + asset_suffix: armv7-linux.tar.gz + + - name: arm64 + os: ubuntu-latest + target: aarch64-unknown-linux-gnu + build_deps: > + gcc-aarch64-linux-gnu + cargo_config: | + [target.aarch64-unknown-linux-gnu] + linker = "aarch64-linux-gnu-gcc" + build_flags: --target aarch64-unknown-linux-gnu + archive_name: age-plugin-yubikey.tar.gz + asset_suffix: arm64-linux.tar.gz + + - name: windows + os: windows-latest + archive_name: age-plugin-yubikey.zip + asset_suffix: x86_64-windows.zip + + - name: macos + os: macos-latest + archive_name: age-plugin-yubikey.tar.gz + asset_suffix: x86_64-darwin.tar.gz + + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Add target + run: rustup target add ${{ matrix.target }} + if: matrix.target != '' + + - name: Install linux build dependencies + run: sudo apt install ${{ matrix.build_deps }} + if: matrix.build_deps != '' + + - name: Set up .cargo/config + run: | + mkdir .cargo + echo '${{ matrix.cargo_config }}' >.cargo/config + if: matrix.cargo_config != '' + + - name: cargo build + run: cargo build --release --locked ${{ matrix.build_flags }} + + - name: Create archive + run: | + mkdir -p release/age-plugin-yubikey + mv target/${{ matrix.target }}/release/age-plugin-yubikey release/age-plugin-yubikey/ + tar czf ${{ matrix.archive_name }} -C release/ age-plugin-yubikey/ + if: matrix.name != 'windows' + + - name: Create archive [Windows] + run: | + mkdir -p release/age-plugin-yubikey + mv target/release/age-plugin-yubikey.exe release/age-plugin-yubikey/ + cd release/ + 7z.exe a ../${{ matrix.archive_name }} age-plugin-yubikey/ + shell: bash + if: matrix.name == 'windows' + + - name: Upload archive to release + uses: svenstaro/upload-release-action@2.2.0 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ matrix.archive_name }} + asset_name: age-plugin-yubikey-$tag-${{ matrix.asset_suffix }} + tag: ${{ github.ref }} + prerelease: true + if: github.event.inputs.test != 'true'