Skip to content

Commit

Permalink
Add GitHub Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
b1thunt3r committed Sep 16, 2020
1 parent d06e4cb commit 0131c33
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Build and Release

on:
push:
branches:
- master
paths:
- "src/**"
- "tests/**"
pull_request:
branches:
- master
paths:
- "src/**"
- "tests/**"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
outputs:
PACKAGE_VERSION: ${{ steps.setup.outputs.PACKAGE_VERSION }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Variables
id: setup
run: |
version=$(grep -oPm1 "(?<=<Version>)[^<]+" Solution.props).$GITHUB_RUN_NUMBER
echo "::set-env name=PACKAGE_VERSION::$version"
echo "::set-output name=PACKAGE_VERSION::$version"
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.401

- name: Install dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --no-restore --verbosity normal

- name: Package
run: dotnet pack --no-restore -c Release -p:Version=$PACKAGE_VERSION

- name: Collect Packages
run: |
mkdir dist
find ./src/ -name "*.nupkg" -exec cp {} dist/ \;
- name: Upoad Artifect
uses: actions/upload-artifact@master
with:
name: nupkg
path: ./dist/*.nupkg

release:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'

steps:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.401

- name: Download Artifact
uses: actions/download-artifact@v1
with:
name: nupkg

- name: Publish nugets to MyGet
run: dotnet nuget push "./nupkg/*.nupkg" --skip-duplicate --no-symbols true --source https://www.myget.org/F/bit0/api/v3/index.json --api-key ${{ secrets.MYGET_API_KEY }}

- name: Publish nugets to GitHub
uses: tanaka-takayoshi/nuget-publish-to-github-packages-action@v2.1
with:
nupkg-path: './nupkg/*.nupkg'
repo-owner: ${{ github.repository_owner }}
gh-user: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Changelog
id: changelog
uses: scottbrenner/generate-changelog-action@master
env:
REPO: ${{ github.repository }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.build.outputs.PACKAGE_VERSION }}
release_name: Release v${{ needs.build.outputs.PACKAGE_VERSION }}
body: |
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
10 changes: 10 additions & 0 deletions Bit0.Plugins.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Common.props = Common.props
LICENSE.txt = LICENSE.txt
README.md = README.md
Solution.props = Solution.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{FC08E61B-2A13-4B02-A176-95D13FB9C738}"
Expand All @@ -26,6 +27,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bit0.Plugins.Loader", "src\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bit0.Plugins.Sdk", "src\Bit0.Plugins.Sdk\Bit0.Plugins.Sdk.csproj", "{8A029FEB-9A2E-4A4E-91E6-AC61CE65E4AD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{D20DC011-6AB1-40A8-97C6-0DF5821A333A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{1ACCAAC9-DAC8-4E3F-A25F-6AB58B7C2938}"
ProjectSection(SolutionItems) = preProject
.github\workflows\package.yml = .github\workflows\package.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -57,6 +65,8 @@ Global
{58FB9B54-428E-408D-9DDC-EC58D007868D} = {49FB92AB-68CE-4575-B817-5E1FC156CA48}
{DE7CB97E-FE46-49EC-9F01-A63072B1B6E7} = {FC08E61B-2A13-4B02-A176-95D13FB9C738}
{8A029FEB-9A2E-4A4E-91E6-AC61CE65E4AD} = {FC08E61B-2A13-4B02-A176-95D13FB9C738}
{D20DC011-6AB1-40A8-97C6-0DF5821A333A} = {D1D6A1CA-7035-4BB6-BBA4-862F1EBC39D7}
{1ACCAAC9-DAC8-4E3F-A25F-6AB58B7C2938} = {D20DC011-6AB1-40A8-97C6-0DF5821A333A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F729AF24-C7AD-4895-B1F5-7BDA64720979}
Expand Down

0 comments on commit 0131c33

Please sign in to comment.