Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions #1

Merged
merged 25 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: build

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
Piedone marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.*
- name: Install dependencies
run: dotnet restore -p:NuGetBuild=True
- name: Build
run: dotnet build --configuration Release --no-restore -p:NuGetBuild=True -p:LangVersion=Latest
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: publish

on:
workflow_call:
inputs:
source:
required: false
type: string
secrets:
apikey:
required: true
Piedone marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: haya14busa/action-cond@v1
id: sourceeval
with:
cond: ${{ inputs.source == '' }}
# default nuget source. TODO change to nuget.org
if_true: "https://nuget.cloudsmith.io/lombiq/open-source-orchard-core-extensions/v3/index.json"
Piedone marked this conversation as resolved.
Show resolved Hide resolved
if_false: "${{ inputs.source == '' }}"
Piedone marked this conversation as resolved.
Show resolved Hide resolved
- name: Print source
run: echo Nuget Source:${{ steps.sourceeval.outputs.value }}
- name: Get the version
id: get_version
run: |
VERSION="${GITHUB_REF_NAME//v}"
echo VERSION:${VERSION}
echo ::set-output name=VERSION::${VERSION}
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.*
- name: Install dependencies
run: dotnet restore -p:NuGetBuild=True
- name: Build
run: dotnet build --configuration Release --no-restore -p:NuGetBuild=True -p:LangVersion=Latest
- name: Pack
run: dotnet pack --output artifacts --configuration Release --no-restore --no-build -p:NuGetBuild=True -p:Version=${{ steps.get_version.outputs.VERSION }} -p:NoWarn=NU5104 -p:TreatWarningsAsErrors=true
- name: Push with dotnet
run: dotnet nuget push artifacts/*.nupkg --api-key ${{ secrets.apikey }} --source ${{ steps.sourceeval.outputs.value }} --skip-duplicate
Piedone marked this conversation as resolved.
Show resolved Hide resolved
- name: Archive artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts
68 changes: 62 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,77 @@
# Lombiq <add project name here>
# Lombiq NuGet Publishing Github Actions



## About

Add a general overview of the project here. Don't forget to update the year in the Licence! Keep or remove the OSOCE note below as necessary.

Do you want to quickly try out this project and see it in action? Check it out in our [Open-Source Orchard Core Extensions](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions) full Orchard Core solution and also see our other useful Orchard Core-related open-source projects!
Github Actions shared between Lombiq projects, used to publish packages to NuGet.


## Documentation

Add detailed documentation here. If it's a lot of content then create documentation pages under the *Docs* folder and link pages here.
This includes two workflows that can be invoked through the `call-build-workflow` step:

- _build.yml_: Builds the project with the .NET SDK.
- _publish.yml_: Builds the project with the .NET SDK and publishes it as a NuGet package to the configured NuGet feed.

To add to a project create a folder from the root of the repository that will call these actions, _.github/workflows/build.yml_ and/or _.github/workflows/publish.yml_.

Example _build.yml_:

```yaml
name: build

on:
push:
branches: [dev]
paths-ignore:
- "Docs/**"
- "Readme.md"

pull_request:
branches: [dev]

jobs:
call-build-workflow:
uses: Lombiq/NuGet-Publishing-GitHub-Actions/.github/workflows/build.yml@v1
```

This workflow is triggered on push to `dev` and pull requests to `dev` and invokes the _build.yml_ workflow from this repository. It takes no parameters.

Example _publish.yml_:

```yaml
name: publish

on:
push:
tags:
- v*

jobs:
call-publish-workflow:
uses: Lombiq/NuGet-Publishing-GitHub-Actions/.github/workflows/publish.yml@v1
secrets:
apikey: ${{ secrets.LOMBIQ_NUGET_PUBLISH_API_KEY }}
```

The _publish.yml_ workflow is triggered on a tag pushed to any branch with the prefix `v` and should contain a version number, e.g. `v1.0.1`, which will be extracted and used to version the NuGet packages produced.

It takes one non-optional secret parameter, `apikey`, the organization API key for pushing to NuGet, and one optional parameter, `source`:

```yaml
uses: Lombiq/NuGet-Publishing-GitHub-Actions/.github/workflows/publish.yml@v1
with:
source: `custom-nuget-source-to-push-too`
```

When `source` is not provided, it assumes a default value of pushing to the [Lombiq NuGet feed](https://www.nuget.org/profiles/Lombiq).

Refer to [Github Actions reusable workflows](https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#overview) for more information.


## Contributing and support

Bug reports, feature requests, comments, questions, code contributions, and love letters are warmly welcome, please do so via GitHub issues and pull requests. Please adhere to our [open-source guidelines](https://lombiq.com/open-source-guidelines) while doing so.

This project is developed by [Lombiq Technologies](https://lombiq.com/). Commercial-grade support is available through Lombiq.
This project is developed by [Lombiq Technologies](https://lombiq.com/). Commercial-grade support is available through Lombiq.