Skip to content

Commit

Permalink
Add bump workflow (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored Oct 2, 2023
1 parent bfbdd41 commit 115ce98
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 12 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -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 "(?<=<Version>)[^<]*")
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/<Version>[^<]*/<Version>${{ 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 }}"
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >
Expand All @@ -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
Expand Down
10 changes: 1 addition & 9 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>

<PropertyGroup>
<Version>2.0.0-beta1</Version>
<CurrentPreviewTfm>net8.0</CurrentPreviewTfm>
<!--<IncludePreview>true</IncludePreview>-->
<IncludePreview Condition="'$(IncludePreview)' == ''">false</IncludePreview>
Expand All @@ -15,15 +16,6 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup>
<PasswordlessMajorVersion>2</PasswordlessMajorVersion>
<PasswordlessMinorVersion>0</PasswordlessMinorVersion>
<PasswordlessPatchVersion>0</PasswordlessPatchVersion>
<PasswordlessMajorMinorVersion>$(PasswordlessMajorVersion).$(PasswordlessMinorVersion)</PasswordlessMajorMinorVersion>
<VersionPrefix>$(PasswordlessMajorMinorVersion).$(PasswordlessPatchVersion)</VersionPrefix>
<VersionSuffix>beta1</VersionSuffix>
</PropertyGroup>

<ItemGroup>
<!--
The .NET Framework target doesn't seem to like this implicit using so we
Expand Down

0 comments on commit 115ce98

Please sign in to comment.