From b14fa9547f10d0c6360d85688db3e8d00dd34a4e Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Sat, 14 Nov 2020 09:40:07 +0100 Subject: [PATCH] Added first workflows for building docs and ci/cd --- .github/workflows/cicd.yaml | 27 +++++++++++++++++++++++++++ .github/workflows/docs.yaml | 18 ++++++++++++++++++ SpotifyAPI.Docs/docs.sh | 22 +++++++++------------- publish.sh | 34 ++++++++++++++++------------------ 4 files changed, 70 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/cicd.yaml create mode 100644 .github/workflows/docs.yaml diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml new file mode 100644 index 00000000..b1d12621 --- /dev/null +++ b/.github/workflows/cicd.yaml @@ -0,0 +1,27 @@ +name: Build/Test/Release SpotifyAPI-NET + +on: + push: + pull_request: + +jobs: + spotifyapi-net-cicd: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: "3.1.x" + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: "2.2.x" + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: "5.0.x" + - name: Restore Packages + run: dotnet restore + - name: Build + run: dotnet build --configuration Release --verbosity minimal + - name: Test + run: dotnet test SpotifyAPI.Web.Tests diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 00000000..f915a721 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,18 @@ +name: Build/Deploy Documentation + +on: + push: + branches: [$default-branch] + +jobs: + build-deploy-docs: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Use Node.JS + uses: actions/setup-node@v1 + with: + node-version: 14.15.0 + - name: Build & Deploy Documentation + run: ./SpotifyAPI.Docs/docs.sh diff --git a/SpotifyAPI.Docs/docs.sh b/SpotifyAPI.Docs/docs.sh index f277a958..b9ba185b 100755 --- a/SpotifyAPI.Docs/docs.sh +++ b/SpotifyAPI.Docs/docs.sh @@ -2,19 +2,15 @@ set -e -if [ -z "$APPVEYOR_PULL_REQUEST_NUMBER" ]; then - if [ "$APPVEYOR_REPO_BRANCH" = "master" ]; then - echo "Building docs..." +echo "Building docs..." - echo "$GH_DEPLOY_TOKEN" | base64 -d > "$HOME/.ssh/id_rsa" - chmod 700 ~/.ssh - chmod 600 ~/.ssh/id_rsa +echo "$GH_DEPLOY_TOKEN" | base64 -d > "$HOME/.ssh/id_rsa" +chmod 700 ~/.ssh +chmod 600 ~/.ssh/id_rsa - git config --global user.email "jonas@dellinger.dev" - git config --global user.name "AppVeyor Docs Builder" +git config --global user.email "jonas@dellinger.dev" +git config --global user.name "GH Actions Docs Builder" - cd ./SpotifyAPI.Docs - yarn - USE_SSH=true GIT_USER=JohnnyCrazy yarn deploy - fi -fi +cd ./SpotifyAPI.Docs +yarn +USE_SSH=true GIT_USER=JohnnyCrazy yarn deploy diff --git a/publish.sh b/publish.sh index ab46750f..fa35a2ce 100755 --- a/publish.sh +++ b/publish.sh @@ -2,25 +2,23 @@ set -e -if [ "$APPVEYOR_REPO_TAG" = "true" ]; then - echo "Publishing..." +echo "Publishing..." - sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - alias nuget="mono /usr/local/bin/nuget.exe" +sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe +alias nuget="mono /usr/local/bin/nuget.exe" - cd ./SpotifyAPI.Web - dotnet pack -c Release SpotifyAPI.Web.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME" - nuget push "./bin/Release/SpotifyAPI.Web.$APPVEYOR_REPO_TAG_NAME.nupkg"\ - -ApiKey "$NUGET_TOKEN"\ - -NonInteractive\ - -Source https://www.nuget.org/api/v2/package +cd ./SpotifyAPI.Web +dotnet pack -c Release SpotifyAPI.Web.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME" +nuget push "./bin/Release/SpotifyAPI.Web.$APPVEYOR_REPO_TAG_NAME.nupkg"\ + -ApiKey "$NUGET_TOKEN"\ + -NonInteractive\ + -Source https://www.nuget.org/api/v2/package - cd ../SpotifyAPI.Web.Auth - dotnet pack -c Release SpotifyAPI.Web.Auth.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME" - nuget push "./bin/Release/SpotifyAPI.Web.Auth.$APPVEYOR_REPO_TAG_NAME.nupkg"\ - -ApiKey "$NUGET_TOKEN"\ - -NonInteractive\ - -Source https://www.nuget.org/api/v2/package +cd ../SpotifyAPI.Web.Auth +dotnet pack -c Release SpotifyAPI.Web.Auth.csproj -p:PackageVersion="$APPVEYOR_REPO_TAG_NAME" +nuget push "./bin/Release/SpotifyAPI.Web.Auth.$APPVEYOR_REPO_TAG_NAME.nupkg"\ + -ApiKey "$NUGET_TOKEN"\ + -NonInteractive\ + -Source https://www.nuget.org/api/v2/package - cd .. -fi +cd ..