diff --git a/.github/workflows/deploy_cargo_cyclonedx.yml b/.github/workflows/deploy_cargo_cyclonedx.yml index 32cb4d83..79833003 100644 --- a/.github/workflows/deploy_cargo_cyclonedx.yml +++ b/.github/workflows/deploy_cargo_cyclonedx.yml @@ -42,3 +42,89 @@ jobs: git commit -am "New development bump of cargo-cylonedx to ${{steps.version.outputs.CARGO_VERSION}}" git tag -a "cargo-cyclonedx-${{steps.version.outputs.CARGO_VERSION}}" -m "cargo-cyclonedx ${{steps.version.outputs.CARGO_VERSION}} release" git push --follow-tags + + build-prod: + name: Build prod - ${{ matrix.name }} + needs: deploy + strategy: + fail-fast: false + matrix: + include: + - name: linux-amd64 + runner: ubuntu-latest + target: x86_64-unknown-linux-gnu + bin: cargo-cyclonedx + zip: cargo-cyclonedx-linux-amd64.tar.gz + # - name: win-amd64 + # runner: windows-latest + # target: x86_64-pc-windows-msvc + # bin: cargo-cyclonedx.exe + # zip: cargo-cyclonedx-Win-x86_64.zip + - name: macos-amd64 + runner: macos-latest + target: x86_64-apple-darwin + bin: cargo-cyclonedx + zip: cargo-cyclonedx-Darwin-x86_64.tar.gz + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout release tag + run: | + echo "${{ needs.deploy.outputs.TAG_NAME }}" + git checkout ${{ needs.deploy.outputs.TAG_NAME }} + git status + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: "${{ matrix.target }}" + + - uses: Swatinem/rust-cache@v2 + + - name: Build ${{ matrix.name }} binary + run: cargo build --verbose --locked --release --target ${{ matrix.target }} + + - name: Package as archive + shell: bash + run: | + mkdir out + cd target/${{ matrix.target }}/release + if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then + mv cargo-cyclonedx ${{ matrix.bin }} + 7z a ../../../out/${{ matrix.zip }} ${{ matrix.bin }} + else + tar czvf ../../../out/${{ matrix.zip }} ${{ matrix.bin }} + fi + cd - + shasum -a 256 out/${{ matrix.zip }} > out/${{ matrix.zip }}.sha256 + + - uses: actions/upload-artifact@v3 + with: + name: cyclonedx-${{ matrix.target }} + path: "out/*" + + release: + needs: [deploy, build-prod] + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: Review and move artifacts + run: | + mkdir dist + find artifacts -type f -exec mv {} dist \; + + - name: Release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: "cyclonedx-bom-${{ needs.deploy.outputs.TAG_NAME }}" + tag_name: ${{ needs.deploy.outputs.TAG_NAME }} + files: "dist/*"