Skip to content

Fix release pipeline (#74) #67

Fix release pipeline (#74)

Fix release pipeline (#74) #67

Workflow file for this run

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: Restore dependencies
run: dotnet restore "./src/Vipps.net/Vipps.net.csproj"
# Create Nuget package.
- 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: Install Paket
run: dotnet tool install Paket --tool-path .paket
- name: Install dependencies
run: |
.paket/paket install
working-directory: ./src
- 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: "echo \"RELEASE_TAG=v$(find ./out -maxdepth 1 -name Vipps.net.*.nupkg | grep -oP '((\\d+)\\.(\\d+)\\.(\\d+)(.*?))')\" >> $GITHUB_ENV"
- name: Configure git username
run: git config user.name github-actions-bot
- name: Configure git user email
run: git config user.email [email protected]
# Create git tag
- name: Create Tag
run: git tag ${{ 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 }} out/* --clobber
# Publish Nuget package
- name: Publish Nuget package
run: dotnet nuget push out/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json