mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-25 06:14:31 +00:00
aa092bdd67
Action to build, publish and validate release
105 lines
3.6 KiB
YAML
105 lines
3.6 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v1
|
|
with:
|
|
dotnet-version: "8.x"
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore NebulaAuth.sln
|
|
|
|
- name: Build
|
|
run: dotnet build NebulaAuth.sln --configuration Release
|
|
|
|
- name: Get version from assembly
|
|
id: get-version
|
|
run: |
|
|
VERSION=$(grep -oP '(?<=<AssemblyVersion>)[^<]+' NebulaAuth/NebulaAuth.csproj)
|
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
|
|
- name: Check if tag exists
|
|
id: tag_exists
|
|
run: |
|
|
if git tag -l | grep -q "^${{ env.VERSION }}$"; then
|
|
echo "Version ${{ env.VERSION }} already exists."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Check changelog
|
|
run: |
|
|
if [ ! -f "changelog/${{ env.VERSION }}.html" ]; then
|
|
echo "Changelog file changelog/${{ env.VERSION }}.html does not exist."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Insert date into changelog
|
|
run: |
|
|
DATE=$(date +"%d.%m.%Y")
|
|
sed -i "s|<div class=\"date\">.*</div>|<div class=\"date\">$DATE</div>|" changelog/${{ env.VERSION }}.html
|
|
|
|
- name: Extract changelog description
|
|
id: extract_description
|
|
run: |
|
|
DESCRIPTION=$(grep -oP '(?<=<div class="description">).*(?=</div>)' changelog/${{ env.VERSION }}.html | sed 's/<br\/>/\n/g')
|
|
echo "DESCRIPTION=$DESCRIPTION" >> $GITHUB_ENV
|
|
|
|
|
|
- name: Create ZIP
|
|
run: |
|
|
mkdir -p release
|
|
zip -r release/NebulaAuth.${{ env.VERSION }}.zip NebulaAuth/bin/Release
|
|
|
|
- name: Create GitHub Release
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ env.VERSION }}
|
|
release_name: NebulaAuth ${{ env.VERSION }}
|
|
body: |
|
|
${{ env.DESCRIPTION }}
|
|
[Download NebulaAuth.${{ env.VERSION }}.zip](https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/NebulaAuth.${{ env.VERSION }}.zip)
|
|
draft: false
|
|
prerelease: false
|
|
|
|
- name: Upload Release Asset
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: release/NebulaAuth.${{ env.VERSION }}.zip
|
|
asset_name: NebulaAuth.${{ env.VERSION }}.zip
|
|
asset_content_type: application/zip
|
|
|
|
- name: Update XML and Changelog html
|
|
run: |
|
|
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > update.xml
|
|
echo "<item>" >> update.xml
|
|
echo " <version>${{ env.VERSION }}.0</version>" >> update.xml
|
|
echo " <url>https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/NebulaAuth.${{ env.VERSION }}.zip</url>" >> update.xml
|
|
echo " <changelog>https://achiez.github.io/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/changelog/${{ env.VERSION }}.html</changelog>" >> update.xml
|
|
echo " <mandatory>false</mandatory>" >> update.xml
|
|
echo "</item>" >> update.xml
|
|
git config --global user.name 'github-actions'
|
|
git config --global user.email 'github-actions@github.com'
|
|
git add changelog/${{ env.VERSION }}.html update.xml
|
|
git commit -m "Update version to ${{ env.VERSION }} and add changelog"
|
|
git push origin master
|