Skip to content

Commit

Permalink
Add packaging to project files and release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
coderpatros committed Oct 19, 2020
1 parent 7bd1c8b commit 965b966
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 151 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 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/[email protected]

# The tests should have already been run during the PR workflow, so this is really just a sanity check
- 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 build --configuration Release
dotnet pack --configuration Release --version-suffix $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.Models.${{ steps.package_release.outputs.version }}.nupkg
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" ./nupkgs/CycloneDX.Json.${{ steps.package_release.outputs.version }}.nupkg
dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" ./nupkgs/CycloneDX.Xml.${{ steps.package_release.outputs.version }}.nupkg
- name: Create github release and git tag for release
id: create_release
uses: actions/create-release@v1
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.Models.${{ steps.package_release.outputs.version }}.nupkg
asset_name: CycloneDX.Models.${{ 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.Json.${{ steps.package_release.outputs.version }}.nupkg
asset_name: CycloneDX.Json.${{ 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.Xml.${{ steps.package_release.outputs.version }}.nupkg
asset_name: CycloneDX.Xml.${{ steps.package_release.outputs.version }}.nupkg
asset_content_type: application/zip
140 changes: 0 additions & 140 deletions .github/workflows/release.yml.tmp

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/.vscode/
bin/
obj/
packages/
nupkgs/
coverage-report/
coverage.cobertura.xml
*/__snapshots__/__mismatch__/
18 changes: 14 additions & 4 deletions CycloneDX.Json/CycloneDX.Json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Product>CycloneDX.Json</Product>
<Authors>Steve Springett</Authors>
<Copyright>Copyright (c) Steve Springett</Copyright>
<Description>A .NET Standard library for serializing and deserializing JSON format CycloneDX bill-of-material documents.</Description>
<PackageId>CycloneDX.Json</PackageId>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/CycloneDX/cyclonedx-dotnet-library</PackageProjectUrl>
<PackageVersion>$(VersionSuffix)</PackageVersion>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/CycloneDX/cyclonedx-dotnet-library.git</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.2" />
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CycloneDX.Models\CycloneDX.Models.csproj" />
<ItemGroup>
<ProjectReference Include="..\CycloneDX.Models\CycloneDX.Models.csproj" />
</ItemGroup>

</Project>
14 changes: 12 additions & 2 deletions CycloneDX.Models/CycloneDX.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Product>CycloneDX.Models</Product>
<Authors>Steve Springett</Authors>
<Copyright>Copyright (c) Steve Springett</Copyright>
<Description>A .NET Standard library of data models for CycloneDX bill-of-material documents.</Description>
<PackageId>CycloneDX.Models</PackageId>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/CycloneDX/cyclonedx-dotnet-library</PackageProjectUrl>
<PackageVersion>$(VersionSuffix)</PackageVersion>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/CycloneDX/cyclonedx-dotnet-library.git</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.2" />
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup>

</Project>
18 changes: 14 additions & 4 deletions CycloneDX.Xml/CycloneDX.Xml.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\CycloneDX.Models\CycloneDX.Models.csproj" />
</ItemGroup>

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Product>CycloneDX.Xml</Product>
<Authors>Steve Springett</Authors>
<Copyright>Copyright (c) Steve Springett</Copyright>
<Description>A .NET Standard library for serializing and deserializing XML format CycloneDX bill-of-material documents.</Description>
<PackageId>CycloneDX.Xml</PackageId>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/CycloneDX/cyclonedx-dotnet-library</PackageProjectUrl>
<PackageVersion>$(VersionSuffix)</PackageVersion>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/CycloneDX/cyclonedx-dotnet-library.git</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\CycloneDX.Models\CycloneDX.Models.csproj" />
</ItemGroup>

</Project>

0 comments on commit 965b966

Please sign in to comment.