Include codegen projects in release (#70) #63
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: Restore dependencies | |
run: dotnet restore "./src/Vipps.net/Vipps.net.csproj" | |
# Create Nuget package. | |
- name: Pack Nuget | |
run: dotnet pack "./src/Vipps.net/Vipps.net.csproj" --include-source --include-referenced-projects --output out --configuration Release --no-restore | |
# 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 noreply@vipps.no | |
# 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 |