Skip to content

Commit

Permalink
Add GitHub Actions workflows for testing and publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
aradalvand committed Aug 16, 2023
1 parent f70a823 commit 6971279
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4

[*.{yml,yaml}]
indent_style = space
indent_size = 2
35 changes: 35 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish To NuGet

on:
release: # NOTE: See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
types:
- published

jobs:
# TODO: Have this depend on `test.yaml`
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x" # TODO: Specify multiple .NET versions once we add support for other target frameworks

- name: Generate the package
# NOTE: As for the `${GITHUB_REF_NAME#v}` bit below, see https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables:~:text=branch%2D1.-,GITHUB_REF_NAME,-The%20short%20ref. We could've also done https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable but since we're using this value in a single place, we don't need to make it an environment variable.
run: |
dotnet pack \
--configuration Release
--output _nuget
-p:PackageVersion=${GITHUB_REF_NAME#v}
- name: Push the package to NuGet
run: |
dotnet nuget push \
_nuget\*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_API_KEY }}
23 changes: 23 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run Tests

on:
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x" # TODO: Specify multiple .NET versions once we add support for other target frameworks

# TODO: Some .NET codebases with GitHub Actions workflows seem to run `dotnet restore`, `dotnet build` and `dotnet test` as separate steps. Why?
- name: Run the tests
run: dotnet test --configuration Release
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"cSpell.words": ["Parallelizable", "sqids"]
"cSpell.words": ["nupkg", "Parallelizable", "sqids"]
}
2 changes: 0 additions & 2 deletions src/Sqids/Sqids.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
<OutputType>Library</OutputType>

<PackageId>Sqids</PackageId>
<Version>1.0.4</Version>
<Description>Official .NET port of Sqids. Generate short YouTube-looking IDs from numbers.</Description>
<PackRelease>true</PackRelease>
<PackageTags>Sqids;ID-generator;number-obfuscator;YouTube-ID</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/sqids/sqids-dotnet/main/icon.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
Expand Down

0 comments on commit 6971279

Please sign in to comment.