Fix release 6 (#80) #73
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
env: | |
solution_file: 'src/Vipps.net.sln' | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # needed to push tag | |
strategy: | |
matrix: | |
dotnet-version: [ '8.0.x' ] | |
steps: | |
- name: Get repo with depth | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # needed to calculate version | |
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }} | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ matrix.dotnet-version }} | |
- name: Install Paket | |
run: dotnet tool install Paket --tool-path .paket | |
working-directory: ./src | |
- name: Install dependencies | |
run: | | |
.paket/paket install | |
working-directory: ./src | |
- name: Build project | |
run: | | |
dotnet build "./src/Vipps.net.Models.Checkout" --configuration Release | |
dotnet build "./src/Vipps.net.Models.Epayment" --configuration Release | |
dotnet build "./src/Vipps.net" --configuration Release | |
- name: Pack NuGet Package with Paket | |
run: | | |
.paket/paket pack Vipps.net | |
working-directory: ./src | |
# Setup necessary info to create tag | |
- name: Set tag variable with v, for use in tag and release based on packed NuGet | |
run: | | |
RELEASE_VERSION=$(find ./src/Vipps.net -maxdepth 1 -name 'Vipps.net.*.nupkg' \ | |
| head -n 1 \ | |
| xargs -n 1 basename \ | |
| grep -oP '(\d+\.\d+\.\d+(.*?))') | |
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | |
echo "RELEASE_TAG=v${RELEASE_VERSION}" >> $GITHUB_ENV | |
- name: Configure git username | |
run: git config user.name github-actions-bot | |
- name: Configure git user email | |
run: git config user.email noreply@vipps.no | |
# Create git tag | |
- name: Create Tag | |
run: git tag v${{ env.RELEASE_TAG }} -m ${{ env.RELEASE_TAG }} | |
- name: Publish Tag | |
run: git push --tags | |
# Create git release | |
- name: "Create GitHub Release" | |
uses: "actions/github-script@v6" | |
with: | |
github-token: "${{ secrets.GITHUB_TOKEN }}" | |
script: | | |
try { | |
const response = await github.rest.repos.createRelease({ | |
draft: false, | |
generate_release_notes: true, | |
name: process.env.RELEASE_TAG, | |
owner: context.repo.owner, | |
prerelease: false, | |
repo: context.repo.repo, | |
tag_name: process.env.RELEASE_TAG, | |
}); | |
core.exportVariable('RELEASE_ID', response.data.id); | |
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url); | |
} catch (error) { | |
core.setFailed(error.message); | |
} | |
- name: Upload to GitHub release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG: ${{ env.RELEASE_TAG }} | |
run: | | |
gh release upload ${{ env.RELEASE_TAG }} src/Vipps.net/Vipps.net.${{ env.RELEASE_VERSION }}.nupkg --clobber | |
# Publish Nuget package | |
- name: Publish Nuget package | |
run: dotnet nuget push src/Vipps.net/Vipps.net.${{ env.RELEASE_VERSION }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |