Skip to content

Commit

Permalink
Add prod build and release steps
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Gil León <[email protected]>
  • Loading branch information
keponk committed Oct 23, 2023
1 parent 293fadf commit 52846e6
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/deploy_cargo_cyclonedx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"

0 comments on commit 52846e6

Please sign in to comment.