Skip to content

Commit

Permalink
Extract to build script
Browse files Browse the repository at this point in the history
  • Loading branch information
alexaka1 committed Jul 7, 2024
1 parent 7505db8 commit 5f505c5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,15 @@ jobs:
path: TestResults
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
# - name: Set run permissions
# id: set-perms
# run: |
# chmod +x ./build/version.sh
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
version: |
yarn run version
VERSION=$(jq -r '.version' "${{ env.SERILOG_EXPRESSIONS_FORMATTING_PACKAGE_JSON }}")
sed -i "s#<VersionPrefix>.*</VersionPrefix>#<VersionPrefix>$VERSION</VersionPrefix>#" "${{ env.SERILOG_EXPRESSIONS_FORMATTING_CSPROJ }}"
AVAILABLE_VERSIONS=$(curl -s "https://api.nuget.org/v3-flatcontainer/alexaka1.serilog.expressions.formatting/index.json" | jq -r '.versions[]')
if echo "$AVAILABLE_VERSIONS" | grep -q "^$CURRENT_VERSION$"; then
echo "versionExists=true" >> "$GITHUB_OUTPUT"
else
echo "versionExists=false" >> "$GITHUB_OUTPUT"
fi
version: ./build/version.sh ${{ env.SERILOG_EXPRESSIONS_FORMATTING_PACKAGE_JSON }} ${{ env.SERILOG_EXPRESSIONS_FORMATTING_CSPROJ }} "alexaka1.serilog.extensions.formatting"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
16 changes: 16 additions & 0 deletions build/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

PACKAGE_JSON_PATH=$1
CSPROJ_PATH=$2
PACKAGE_NAME=$2

set -e
yarn run version
VERSION=$(jq -r '.version' "$PACKAGE_JSON_PATH")
sed -i "s#<VersionPrefix>.*</VersionPrefix>#<VersionPrefix>$VERSION</VersionPrefix>#" "$CSPROJ_PATH"
AVAILABLE_VERSIONS=$(curl -s "https://api.nuget.org/v3-flatcontainer/$PACKAGE_NAME/index.json" | jq -r '.versions[]')
if echo "$AVAILABLE_VERSIONS" | grep -q "^$VERSION$"; then
echo "versionExists=true" >> "$GITHUB_OUTPUT"
else
echo "versionExists=false" >> "$GITHUB_OUTPUT"
fi

0 comments on commit 5f505c5

Please sign in to comment.