diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index 9616481..5ada5c9 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -29,7 +29,15 @@ jobs: version=$(echo "$props" | grep -oPm1 "(?<=)[^<]*") echo "version=$version" >> $GITHUB_OUTPUT - - name: Validate new version + - name: Validate new version (format) + # Use regex to make sure the version is 1.2.3 or 1.2.3-ci-abcdef0 + run: | + if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z].*)?$ ]]; then + echo "Invalid version: ${{ inputs.version }}" + exit 1 + fi + + - name: Validate new version (increment) run: > npx semver@7.5.4 "${{ inputs.version }}" --range "> ${{ steps.current-version.outputs.version }}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f737ec0..be7d5c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,13 @@ jobs: - name: Determine stable version id: stable-version if: ${{ github.event_name == 'release' }} - run: echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT + run: | + if ! [[ "${{ github.event.release.tag_name }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z].*)?$ ]]; then + echo "Invalid version: ${{ github.event.release.tag_name }}" + exit 1 + fi + + echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT - name: Determine prerelease version id: pre-version @@ -139,7 +145,7 @@ jobs: --configuration Release -p:ContinuousIntegrationBuild=true - - name: Create packages + - name: Run pack run: > dotnet pack -p:Version=${{ needs.version.outputs.version }}