diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml new file mode 100644 index 0000000..c4088ad --- /dev/null +++ b/.github/workflows/bump.yml @@ -0,0 +1,89 @@ +name: bump + +on: + workflow_dispatch: + inputs: + version: + type: string + required: true + description: Version to bump to + +env: + BUMP_BRANCH_NAME: bump-${{ inputs.version }}-${{ github.run_id }} + +jobs: + # Ensure that the provided version is greater than the current version + validate: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + + - name: Get current version + id: current-version + run: | + props=$(cat Directory.Build.props) + version=$(echo "$props" | grep -oPm1 "(?<=)[^<]*") + echo "version=$version" >> $GITHUB_OUTPUT + + - name: Validate new version + run: > + npx semver@7.5.4 "${{ inputs.version }}" + --range "> ${{ steps.current-version.outputs.version }}" + --include-prerelease + + # Update version and commit + update: + needs: validate + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + + - name: Configure credentials + run: | + git config --local user.email "106330231+passwordless-bot@users.noreply.github.com" + git config --local user.name "passwordless-bot" + + - name: Create branch + run: git checkout -b $BUMP_BRANCH_NAME + + - name: Rewrite version + run: sed -i "s/[^<]*/${{ inputs.version }}/" Directory.Build.props + + - name: Commit changes + run: | + git add Directory.Build.props + git commit -m "Bump version to ${{ inputs.version }}" + + - name: Push changes + run: git push origin $BUMP_BRANCH_NAME + + # Create a pull request + pr: + needs: + - validate + - update + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + + - name: Create pull request + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: > + gh pr create + --base main + --head $BUMP_BRANCH_NAME + --title "Bump version to ${{ inputs.version }}" \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5445d96..e29d0f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -123,10 +123,11 @@ jobs: id: prerelease-version if: ${{ github.event_name != 'release' }} run: | + time=$(date +%s) ref="${{ github.head_ref || github.ref_name }}" ref_clean="${ref/\//-}" - suffix="ci-${ref_clean}-${{ github.run_id }}" - echo "suffix=${suffix}" >> $GITHUB_OUTPUT + suffix="ci-$time-$ref_clean-${{ github.run_id }}" + echo "version=0.0.0-$suffix" >> $GITHUB_OUTPUT - name: Run pack run: > @@ -135,7 +136,7 @@ jobs: --no-build --configuration Release -p:ContinuousIntegrationBuild=true - ${{ steps.prerelease-version.outputs.suffix && format('--version-suffix {0}', steps.prerelease-version.outputs.suffix) || '' }} + ${{ steps.prerelease-version.outputs.version && format('-p:Version={0}', steps.prerelease-version.outputs.version) || '' }} - name: Upload artifacts uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 diff --git a/Directory.Build.props b/Directory.Build.props index 0b98405..c0bb82b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,7 @@ + 2.0.0-beta1 net8.0 false @@ -15,15 +16,6 @@ false - - 2 - 0 - 0 - $(PasswordlessMajorVersion).$(PasswordlessMinorVersion) - $(PasswordlessMajorMinorVersion).$(PasswordlessPatchVersion) - beta1 - -