Release #52
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow is used for publishing the NuGet packages. | |
# | |
# 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-dotnet-library/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 | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '6.0.x' | |
# For the following tests | |
- name: Install protocol buffers compiler | |
run: | | |
wget -O protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip | |
unzip protoc.zip -d $HOME/.local | |
export PATH="$PATH:$HOME/.local/bin" | |
# The tests should have already been run during the PR workflow, so this is really just a sanity check | |
# See issue #285 for info why the symlink is necessary. | |
- name: SnapshooterHotfixSymlinkLinux | |
run: sudo ln -s "$GITHUB_WORKSPACE" /_ | |
shell: bash | |
- name: Tests | |
run: dotnet test | |
# Build and package everything | |
- name: Package release | |
id: package_release | |
run: | | |
VERSION=`cat semver.txt` | |
echo "##[set-output name=version;]$VERSION" | |
dotnet pack --configuration Release /p:Version=$VERSION --output ./nupkgs | |
- name: Publish packages to NuGet | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
run: | | |
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" ./nupkgs/CycloneDX.Core.${{ steps.package_release.outputs.version }}.nupkg | |
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" ./nupkgs/CycloneDX.Utils.${{ steps.package_release.outputs.version }}.nupkg | |
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" ./nupkgs/CycloneDX.Spdx.${{ steps.package_release.outputs.version }}.nupkg | |
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" ./nupkgs/CycloneDX.Spdx.Interop.${{ steps.package_release.outputs.version }}.nupkg | |
- name: Create github release and git tag for release | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
release_name: ${{ steps.package_release.outputs.version }} | |
tag_name: v${{ steps.package_release.outputs.version }} | |
draft: false | |
prerelease: false | |
- name: Upload package to github release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./nupkgs/CycloneDX.Core.${{ steps.package_release.outputs.version }}.nupkg | |
asset_name: CycloneDX.Core.${{ steps.package_release.outputs.version }}.nupkg | |
asset_content_type: application/zip | |
- name: Upload package to github release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./nupkgs/CycloneDX.Core.${{ steps.package_release.outputs.version }}.snupkg | |
asset_name: CycloneDX.Core.${{ steps.package_release.outputs.version }}.snupkg | |
asset_content_type: application/zip | |
- name: Upload package to github release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./nupkgs/CycloneDX.Utils.${{ steps.package_release.outputs.version }}.nupkg | |
asset_name: CycloneDX.Utils.${{ steps.package_release.outputs.version }}.nupkg | |
asset_content_type: application/zip | |
- name: Upload package to github release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./nupkgs/CycloneDX.Utils.${{ steps.package_release.outputs.version }}.snupkg | |
asset_name: CycloneDX.Utils.${{ steps.package_release.outputs.version }}.snupkg | |
asset_content_type: application/zip | |
- name: Upload package to github release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./nupkgs/CycloneDX.Spdx.${{ steps.package_release.outputs.version }}.nupkg | |
asset_name: CycloneDX.Spdx.${{ steps.package_release.outputs.version }}.nupkg | |
asset_content_type: application/zip | |
- name: Upload package to github release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./nupkgs/CycloneDX.Spdx.${{ steps.package_release.outputs.version }}.snupkg | |
asset_name: CycloneDX.Spdx.${{ steps.package_release.outputs.version }}.snupkg | |
asset_content_type: application/zip | |
- name: Upload package to github release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./nupkgs/CycloneDX.Spdx.Interop.${{ steps.package_release.outputs.version }}.nupkg | |
asset_name: CycloneDX.Spdx.Interop.${{ steps.package_release.outputs.version }}.nupkg | |
asset_content_type: application/zip | |
- name: Upload package to github release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./nupkgs/CycloneDX.Spdx.Interop.${{ steps.package_release.outputs.version }}.snupkg | |
asset_name: CycloneDX.Spdx.Interop.${{ steps.package_release.outputs.version }}.snupkg | |
asset_content_type: application/zip |