Skip to content

Release

Release #53

Workflow file for this run

# This workflow is used for publishing the binaries and Docker image.
#
# Before triggering a release the `semver.txt` file should be updated in the
# relevant branch.
#
# When commiting the version change in `semver.txt` the commit message is
# important as it will be used for the release in GitHub.
#
# For an example commit browse to
# https://github.com/CycloneDX/cyclonedx-dotnet/commit/d110af854371374460430bb8438225a7d7a84274.
#
# The resulting release is here
# https://github.com/CycloneDX/cyclonedx-dotnet/releases/tag/v1.0.0.
#
# Releases are triggered manually. This can be done by browsing to
# https://github.com/CycloneDX/cyclonedx-cli/actions?query=workflow%3ARelease
# and selecting "Run workflow". If releasing a patch for a previous version
# make sure the correct branch is selected. It will default to the default
# branch.
name: Release
on:
workflow_dispatch
env:
SNAPSHOOTER_STRICT_MODE: true
jobs:
release:
name: Release
runs-on: ubuntu-20.04
timeout-minutes: 30
outputs:
# Used by the release-osx-arm64 job to upload the osx-arm64 binary
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-dotnet@v3.0.2
with:
dotnet-version: '6.0'
- name: SnapshooterHotfixSymlinkLinux
run: sudo ln -s "$GITHUB_WORKSPACE" /_
shell: bash
# The tests should have already been run during the PR workflow, so this is really just a sanity check
- name: Tests
run: dotnet test
# Create binaries
- name: Create binaries
id: create_binaries
run: |
VERSION=`cat semver.txt`
echo "##[set-output name=version;]$VERSION"
REPO=cyclonedx/cyclonedx-cli
dotnet build --configuration Release
mkdir bin
for runtime in linux-x64 linux-musl-x64 linux-arm linux-arm64 win-x64 win-x86 win-arm win-arm64 osx-x64
do
dotnet publish src/cyclonedx/cyclonedx.csproj -r $runtime --configuration Release /p:Version=$VERSION --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesInSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --output bin/$runtime
done
docker build -f Dockerfile --build-arg VERSION=$VERSION -t $REPO:$VERSION -t $REPO:latest .
- name: Publish Docker image to Docker Hub
env:
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
run: |
REPO=cyclonedx/cyclonedx-cli
docker login --username coderpatros --password "$DOCKER_TOKEN"
docker push $REPO:latest
docker push $REPO:${{ steps.create_binaries.outputs.version }}
- name: Create github release and git tag for release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: ${{ steps.create_binaries.outputs.version }}
tag_name: v${{ steps.create_binaries.outputs.version }}
draft: false
prerelease: false
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux-x64/cyclonedx
asset_name: cyclonedx-linux-x64
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux-musl-x64/cyclonedx
asset_name: cyclonedx-linux-musl-x64
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux-arm/cyclonedx
asset_name: cyclonedx-linux-arm
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/linux-arm64/cyclonedx
asset_name: cyclonedx-linux-arm64
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/win-x64/cyclonedx.exe
asset_name: cyclonedx-win-x64.exe
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/win-x86/cyclonedx.exe
asset_name: cyclonedx-win-x86.exe
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/win-arm/cyclonedx.exe
asset_name: cyclonedx-win-arm.exe
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/win-arm64/cyclonedx.exe
asset_name: cyclonedx-win-arm64.exe
asset_content_type: application/octet-stream
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/osx-x64/cyclonedx
asset_name: cyclonedx-osx-x64
asset_content_type: application/octet-stream
# Binaries for Apple silicon must be signed, which can only be achieved on macOS.
# See https://github.com/dotnet/runtime/issues/49091#issuecomment-797029172
release-osx-arm64:
name: Release osx-arm64
needs: release
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/setup-dotnet@v3.0.2
with:
dotnet-version: '6.0'
- name: Create binary
run: |
VERSION=`cat semver.txt`
echo "##[set-output name=version;]$VERSION"
dotnet build --configuration Release
mkdir bin
dotnet publish src/cyclonedx/cyclonedx.csproj -r osx-arm64 --configuration Release /p:Version=$VERSION --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesInSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --output bin/osx-arm64
# It is enough to "ad-hoc" sign the binary, we don't need a valid developer certificate for now.
- name: Sign binary
run: |
codesign -f -s - bin/osx-arm64/cyclonedx
- name: Upload binary to github release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.release_upload_url }}
asset_path: bin/osx-arm64/cyclonedx
asset_name: cyclonedx-osx-arm64
asset_content_type: application/octet-stream