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: π On Merge to Main, create a tag from the version in csproj | |
on: | |
pull_request: | |
branches: | |
- main | |
types: [closed] | |
jobs: | |
tag-version: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout | |
uses: actions/[email protected] | |
- name: π Extract version from csproj | |
run: | | |
VERSION=$(cat CodeMirror6/CodeMirror6.csproj | grep '<Version>' | sed 's/<\/\?Version>//g' | xargs) | |
if [[ -z "$VERSION" ]]; then | |
echo "Version not found in .csproj file" | |
exit 1 | |
fi | |
echo "Extracted version: $VERSION" | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: π·οΈ Create Tag | |
if: env.VERSION != '' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const version = '${{ env.VERSION }}'; | |
if (!version) { | |
console.log("Version is empty, skipping tag creation."); | |
return; | |
} | |
const tagName = version; | |
const ref = 'refs/tags/' + tagName; | |
console.log(`Creating tag: ${tagName}`); | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: ref, | |
sha: context.sha | |
}).catch(error => { | |
console.error(`Failed to create tag: ${error.message}`); | |
core.setFailed(`Failed to create tag: ${error.message}`); | |
}); | |
- name: π Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
draft: false | |
prerelease: false | |
tag_name: ${{ env.REF }} | |
name: Release ${{ env.VERSION }} | |
generate_release_notes: true | |
body_path: NEW_CHANGELOG.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
REF: refs/tags/${{ env.VERSION }} | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout | |
uses: actions/checkout@v3 | |
- name: π¦ Setup NuGet | |
uses: NuGet/[email protected] | |
- name: π οΈ Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '21' | |
- name: π οΈ Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0.x' | |
- name: π₯ Restore dependencies | |
run: dotnet restore $SOLUTION | |
- name: ποΈ Build library | |
run: dotnet build CodeMirror6 | |
- name: ποΈ Build wasm app | |
run: dotnet build Examples.BlazorWasm | |
- name: π Publish | |
run: | | |
dotnet publish Examples.BlazorWasm -c Release -o ./build | |
cp ./build/wwwroot/index.html ./build/wwwroot/404.html | |
- name: π Set base path | |
run: sed -i 's|<base href="/" />|<base href="/BlazorCodeMirror6/" />|g' ./build/wwwroot/index.html | |
- name: π Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./build/wwwroot | |
- name: π¦ Prepare Nuget package | |
run: dotnet pack --configuration Release --include-symbols --include-source | |
- name: π Publish to NuGet | |
run: dotnet nuget push "**/*.nupkg" --source "https://api.nuget.org/v3/index.json" -k ${{ secrets.NUGET_API_KEY }} |