From a9a815d520ca50affc4e38623ec3d17333e668df Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 21:57:28 +0100 Subject: [PATCH 01/10] #1 | CHANGED: publish.yml - Manual Pack and Publish. --- .github/workflows/publish.yml | 51 ++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 116d862..ce60033 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,30 +22,45 @@ jobs: # See also: https://github.com/actions/virtual-environments/issues/1891 - uses: actions/setup-dotnet@v1 - name: Setup dotnet + name: Setup DotNet CLI 5.0.x with: dotnet-version: 5.0.x - - name: Calculate Version + - name: Build and Run Tests shell: bash env: DOTNET_CLI_TELEMETRY_OPTOUT: true run: | - # Installs Minver-CLI - dotnet tool install -g minver-cli --version 2.3.1 + dotnet build --configuration Release + dotnet test ./**/bin/**/net*/*Tests.dll + + - name: Pack and Publish to Nuget + shell: bash + env: + DOTNET_CLI_TELEMETRY_OPTOUT: true + NUGET_KEY: ${{secrets.NUGET_API_KEY}} + run: | + dotnet pack + dotnet nuget push ./**/bin/**/*.nupkg --api-key $NUGET_KEY --source https://api.nuget.org/v3/index.json - # Gets the version number - MINVER_VERSION=$(minver --auto-increment patch --tag-prefix v --verbosity t) + # See also: https://itnext.io/creating-a-github-action-to-tag-commits-2722f1560dec + - name: Add Git-Tag corresponding Current SEMVER-Version + shell: bash + env: + DOTNET_CLI_TELEMETRY_OPTOUT: true + run: | + dotnet tool install -g minver-cli --version 2.3.1 + version=$(minver --auto-increment patch --tag-prefix v --verbosity t) + commit=$(git rev-parse HEAD) + remote=$(git config --get remote.origin.url) + repo=$(basename $remote .git) + # POST a new ref to repo via Github API + curl -s -X POST https://api.github.com/repos/$REPO_OWNER/$repo/git/refs \ + -H "Authorization: token $GITHUB_TOKEN" \ + -d @- << EOF + { + "ref": "refs/tags/$version", + "sha": "$commit" + } + EOF - # See also: https://github.com/marketplace/actions/publish-nuget - - uses: rohith/publish-nuget@v2 - name: Build and publish Nuget-Package 'TitanShark.Thresher.Core' - with: - PROJECT_FILE_PATH: TitanShark.Thresher.Core/TitanShark.Thresher.Core.csproj - PACKAGE_NAME: TitanShark.Thresher.Core - VERSION_STATIC: ${{env.MINVER_VERSION}} - TAG_COMMIT: true - TAG_FORMAT: v* - NUGET_SOURCE: https://api.nuget.org - NUGET_KEY: ${{secrets.NUGET_API_KEY}} - INCLUDE_SYMBOLS: false \ No newline at end of file From 17fd5573bf63dd4d3a5b7f75a9352c49cf867493 Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 22:06:10 +0100 Subject: [PATCH 02/10] #1 | CHANGED: publish.yaml - Remove indent by EOF. --- .github/workflows/publish.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ce60033..d09ebdb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -56,11 +56,11 @@ jobs: repo=$(basename $remote .git) # POST a new ref to repo via Github API curl -s -X POST https://api.github.com/repos/$REPO_OWNER/$repo/git/refs \ - -H "Authorization: token $GITHUB_TOKEN" \ - -d @- << EOF - { - "ref": "refs/tags/$version", - "sha": "$commit" - } - EOF + -H "Authorization: token $GITHUB_TOKEN" \ + -d @- << EOF + { + "ref": "refs/tags/$version", + "sha": "$commit" + } + EOF From 294e3095a798dbd766318eac41075506d5a800b0 Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 22:16:42 +0100 Subject: [PATCH 03/10] #1 | CHANGED: publish.yml - Commit Tag. --- .github/workflows/publish.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d09ebdb..0c0a731 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -52,11 +52,8 @@ jobs: dotnet tool install -g minver-cli --version 2.3.1 version=$(minver --auto-increment patch --tag-prefix v --verbosity t) commit=$(git rev-parse HEAD) - remote=$(git config --get remote.origin.url) - repo=$(basename $remote .git) # POST a new ref to repo via Github API - curl -s -X POST https://api.github.com/repos/$REPO_OWNER/$repo/git/refs \ - -H "Authorization: token $GITHUB_TOKEN" \ + curl -s -X POST $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/git/refs \ -d @- << EOF { "ref": "refs/tags/$version", From 7857abce41003d9f1355eedecb6748e5a7c330b1 Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 22:20:46 +0100 Subject: [PATCH 04/10] #1 | CHANGED: pubish.yml - Change Post Ref. --- .github/workflows/publish.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0c0a731..025cccb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -52,8 +52,10 @@ jobs: dotnet tool install -g minver-cli --version 2.3.1 version=$(minver --auto-increment patch --tag-prefix v --verbosity t) commit=$(git rev-parse HEAD) + remote=$(git config --get remote.origin.url) + repo=$(basename $remote .git) # POST a new ref to repo via Github API - curl -s -X POST $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/git/refs \ + curl -s -X POST https://api.github.com/repos/$REPO_OWNER/$repo/git/refs \ -d @- << EOF { "ref": "refs/tags/$version", From f4e5c57da9b80d0a30cf8284edecbcfb0ee4ca13 Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 22:41:15 +0100 Subject: [PATCH 05/10] #1 | CHANGED: publish.yml - Added Bearer with GitHub Token. --- .github/workflows/publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 025cccb..5ac30a1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -56,6 +56,8 @@ jobs: repo=$(basename $remote .git) # POST a new ref to repo via Github API curl -s -X POST https://api.github.com/repos/$REPO_OWNER/$repo/git/refs \ + --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'content-type: application/json' \ -d @- << EOF { "ref": "refs/tags/$version", From 46e4a03754abb4d3e5095af3e38f99401dfea47b Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 22:45:48 +0100 Subject: [PATCH 06/10] #1 | CHANGED: publish.yml - Auth with Token instead Bearer. --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5ac30a1..3d1a667 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -56,7 +56,7 @@ jobs: repo=$(basename $remote .git) # POST a new ref to repo via Github API curl -s -X POST https://api.github.com/repos/$REPO_OWNER/$repo/git/refs \ - --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'authorization: token ${{ secrets.GITHUB_TOKEN }}' \ --header 'content-type: application/json' \ -d @- << EOF { From 6baf425f3d46b9d47e02ff67306ca36e17f6b054 Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 22:52:00 +0100 Subject: [PATCH 07/10] #1 | CHANGED: publish.yml - Used AuthToken. --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3d1a667..227a075 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -56,7 +56,7 @@ jobs: repo=$(basename $remote .git) # POST a new ref to repo via Github API curl -s -X POST https://api.github.com/repos/$REPO_OWNER/$repo/git/refs \ - --header 'authorization: token ${{ secrets.GITHUB_TOKEN }}' \ + --header 'authToken: ${{ secrets.GITHUB_TOKEN }}' \ --header 'content-type: application/json' \ -d @- << EOF { From 8dda2c5d68fc4415f5bc8565cd401177c0827d9f Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 22:58:36 +0100 Subject: [PATCH 08/10] #1 | CHANGED: publish.yml - Used double quotes. --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 227a075..868b1e6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -56,8 +56,8 @@ jobs: repo=$(basename $remote .git) # POST a new ref to repo via Github API curl -s -X POST https://api.github.com/repos/$REPO_OWNER/$repo/git/refs \ - --header 'authToken: ${{ secrets.GITHUB_TOKEN }}' \ - --header 'content-type: application/json' \ + --header "authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + --header "content-type: application/json" \ -d @- << EOF { "ref": "refs/tags/$version", From 259f44e1d870106b94038794bc1418100aa08cee Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 23:10:35 +0100 Subject: [PATCH 09/10] #1 | CHANGED: publish.yml - Used Git Commands for Tagging. --- .github/workflows/publish.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 868b1e6..52534bb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -51,17 +51,6 @@ jobs: run: | dotnet tool install -g minver-cli --version 2.3.1 version=$(minver --auto-increment patch --tag-prefix v --verbosity t) - commit=$(git rev-parse HEAD) - remote=$(git config --get remote.origin.url) - repo=$(basename $remote .git) - # POST a new ref to repo via Github API - curl -s -X POST https://api.github.com/repos/$REPO_OWNER/$repo/git/refs \ - --header "authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - --header "content-type: application/json" \ - -d @- << EOF - { - "ref": "refs/tags/$version", - "sha": "$commit" - } - EOF + git tag $version + git push origin $version From c132f1097f18a112904dfe7138cdc54507fbf0f6 Mon Sep 17 00:00:00 2001 From: Lan Luu Date: Sun, 13 Dec 2020 23:19:43 +0100 Subject: [PATCH 10/10] CHANGED: publish.yml - Add v before Version by Tagging. --- .github/workflows/publish.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 52534bb..3d82cdd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -51,6 +51,7 @@ jobs: run: | dotnet tool install -g minver-cli --version 2.3.1 version=$(minver --auto-increment patch --tag-prefix v --verbosity t) - git tag $version - git push origin $version + tag="v${version}" + git tag $tag + git push origin $tag