debug ci/cd #15
Workflow file for this run
This file contains hidden or 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
on: | |
push: | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+' | |
- '[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+' | |
- '[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+' | |
- '[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+' | |
name: release | |
jobs: | |
release: | |
name: release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Get ref info | |
id: ref_info | |
run: | | |
echo "1" | |
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
echo "2" | |
if [[ -z ${GIT_TAG} ]] || [[ ${GIT_TAG} == refs/heads/* ]]; then exit 1; else appversion=${GIT_TAG}; fi | |
echo "3" | |
echo "VERSION=${appversion}" >> $GITHUB_OUTPUT | |
echo "4" | |
if [[ ${GIT_TAG} =~ (alpha|beta|rc) ]]; then echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT; else echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT; fi | |
echo "5" | |
if [[ ${GIT_TAG} =~ (alpha|beta|rc) ]]; then echo "MAKE_LATEST=false" >> $GITHUB_OUTPUT; else echo "MAKE_LATEST=true" >> $GITHUB_OUTPUT; fi | |
- name: Replace project version | |
env: | |
VERSION: ${{ steps.ref_info.outputs.VERSION }} | |
# replace <Version>0.0.1</Version> with <Version>$GIT_TAG</Version> | |
# in "./WinSyncScroll/WinSyncScroll.csproj" | |
run: | | |
sed -i "s/<Version>.*<\/Version>/<Version>${VERSION}<\/Version>/" ./WinSyncScroll/WinSyncScroll.csproj | |
- name: Generate release notes | |
uses: actions/github-script@v7 | |
env: | |
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | |
VERSION: ${{ steps.ref_info.outputs.VERSION }} | |
with: | |
script: | | |
const { repo, owner } = context.repo; | |
const draft = true; | |
let version = process.env.VERSION; | |
if (version.startsWith('v')) { | |
version = version.slice(1); | |
} | |
const tag_name = version; | |
const name = tag_name; | |
const { data: notes } = await github.rest.repos.generateReleaseNotes({ | |
owner, | |
repo, | |
tag_name, | |
target_commitish: process.env.DEFAULT_BRANCH, | |
}); | |
require('fs').writeFileSync('release_notes.md', notes); | |
- name: Build | |
working-directory: ./WinSyncScroll | |
run: | | |
dotnet publish -c release -r win-x64 --framework net8.0-windows --self-contained | |
dotnet publish -c release -r win-x64 --framework net462 | |
7z a WinSyncScroll_win-x64_net8.0-windows.zip ./bin/release/net8.0-windows/win-x64/publish/* | |
7z a WinSyncScroll_win-x64_net462.zip ./bin/release/net462/win-x64/publish/* | |
- name: Publish | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
prerelease: ${{ steps.ref_info.outputs.IS_PRERELEASE }} | |
make_latest: ${{ steps.ref_info.outputs.MAKE_LATEST }} | |
body_path: release_notes.md | |
files: | | |
./WinSyncScroll/WinSyncScroll_win-x64_net8.0-windows.zip | |
./WinSyncScroll/WinSyncScroll_win-x64_net462.zip |