Skip to content

Add CI workflow

Add CI workflow #51

Workflow file for this run

name: Release
on:
pull_request:
branches:
- master
types: [closed]
jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0"
- name: Get current version
run: |
VERSION=$(node -p "require('./package.json').version")
echo VERSION=$VERSION >> $GITHUB_ENV
echo VERSION_TAG=v$VERSION >> $GITHUB_ENV
- name: Check if tag exists
id: check_tag
run: echo PERFORM_PUBLISH=$(git rev-parse --verify -q "refs/tags/${{ env.VERSION_TAG }}" >> /dev/null && echo false || echo true) >> $GITHUB_ENV
- name: Add GitHub NuGet Registry
if: ${{ env.PERFORM_PUBLISH == 'true' }}
run: dotnet nuget add source --username "GeoWerkstatt-Build" --password "%GITHUB_TOKEN%" --store-password-in-clear-text --name github "https://nuget.pkg.github.com/GeoWerkstatt/index.json"
- name: Restore packages
if: ${{ env.PERFORM_PUBLISH == 'true' }}
run: dotnet restore ./language-server/src
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build language-server
if: ${{ env.PERFORM_PUBLISH == 'true' }}
run: dotnet build --no-restore "-p:VersionPrefix=${{ env.VERSION }}" ./language-server/src
- name: Run language-server tests
if: ${{ env.PERFORM_PUBLISH == 'true' }}
run: dotnet test --no-build ./language-server/src
- name: Publish language-server
if: ${{ env.PERFORM_PUBLISH == 'true' }}
run: |
for rid in win-x64 linux-x64 osx-x64
do
dotnet publish ./language-server/src/Geowerkstatt.Interlis.LanguageServer --self-contained -c Release -r $rid "-p:VersionPrefix=${{ env.VERSION }}" -o ./language-server/bin/$rid
done
- name: Install packages
if: ${{ env.PERFORM_PUBLISH == 'true' }}
run: npm ci
- name: Publish extension
if: ${{ env.PERFORM_PUBLISH == 'true' }}
run: npx vsce publish
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
- name: Tag current version
if: ${{ env.PERFORM_PUBLISH == 'true' }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GeoWerkstatt-Build"
git tag ${{ env.VERSION_TAG }}
- name: Push version tag
if: ${{ env.PERFORM_PUBLISH == 'true' }}
uses: ad-m/github-push-action@057a6ba835d986bfe495dd476a6c4db1d5f9503c
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true