From a92550e050dc6bc08fb53ef4c96f785b327cb752 Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 31 Jan 2024 02:08:37 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20GitHub=20action=20to=20automate?= =?UTF-8?q?=20release=20based=20on=20semantic=20versioning=20(#499)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: add release.yml to help automate release versions * ci: add release.yml to help automate release versions - edited file further to cover edge cases * ci: add release.yml to help automate release versions - I had a typo in a line which pointed at a different variable * ci: add release.yml to help automate release versions - Fixing the release portion to prepend a v * ci: add release.yml to help automate release versions. Lowercased V so it looks like v1.1.0 instead of V1.1.0 * ci: changing structure of release.yml to be easier to understand * ci: #minor changes made * ci: #minor changes made to make rolling and stable both release branches * ci: #minor changes to hopefully turn off pre-release * ci: #minor change - trying to make pre-release suffic set to nothing * ci: #minor change - removed older release action for a better up to date one * ci: #minor change * ci: #minor change to fixed the pre-release issue * ci: #minor change to fixed the pre-release issue again * ci: #minor change to fixed the pre-release issue again2 * ci: changed action for tag. I believe it was causing errors * ci: missing } * ci: testing some things * ci: fixing self inflicted error where I forgot to put an ID in * ci: fixing to make the release branch rolling * major: testing updating major * BREAKING CHANGE: removed changelog action * ci: reset commit and removed changelog * ci: changed action for tag. I believe it was causing errors * ci: missing } * ci: testing some things * ci: fixing self inflicted error where I forgot to put an ID in * ci: fixing to make the release branch rolling * ci: reset commit and removed changelog * ci: added step to change Cargo.toml app version to the latest tag version without the v * ci: using echo and double quotes in the appversion variable. Testing now * ci: testing autocommit * Apply automatic changes * ci: testing autocommit further * ci: testing autocommit: removing tagging since it creates another tag instead of using that tag * Apply automatic changes * ci: testing autocommit with branch protection and doing a PR to rolling * Apply automatic changes * ci: testing PR create and merge - removed the if that was causing it not to run * ci: testing PR create and merge - removed the if that was causing it not to run * Apply automatic changes * ci: testing PR create and merge - fixed permission issues * ci: testing PR create and merge - fixed permission issues * Apply automatic changes * ci: testing PR create and merge - potentially fixed PR issue * Apply automatic changes * ci: testing PR create and merge - potentially fixed PR issue2 * ci: testing PR create and merge - potentially fixed PR issue + fixing what branch it targets * ci: testing PR create and merge - testing PAT * ci: testing PR create and merge - testing to see if merge loop stops * ci: adding in cargo.toml version in auto git commit * Update Cargo.toml Co-authored-by: alamin655 <129589283+alamin655@users.noreply.github.com> * ci: adding in steps to regenerate the Cargo.lock file * ci: adding in steps to regenerate the Cargo.lock file - fixing commit issue with cargo.toml --------- Co-authored-by: scottc943 Co-authored-by: alamin655 <129589283+alamin655@users.noreply.github.com> --- .github/workflows/release.yml | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..57c5100 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,72 @@ +name: Bump release version +on: + pull_request: + branches: [rolling] + types: + - closed + +permissions: + contents: write + pull-requests: write + repository-projects: write + +concurrency: production + +jobs: + build: + name: bump tag version and release + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + fetch-depth: 0 + - name: Bump version and push tag + id: version-bump + uses: hennejg/github-tag-action@v4.3.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + release_branches: rolling + - name: create branch + uses: peterjgrainger/action-create-branch@v2.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: update-from-${{ github.sha }} + - name: update cargo.toml + run: | + appversion=$(echo "${{ steps.version-bump.outputs.new_tag }}" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') + sed -i -e "s/^version = .*/version = \"$appversion\"/" Cargo.toml + - run: rustup toolchain install stable --profile minimal + - run: rustup update stable && rustup default stable + - name: regenerate cargo.lock + run: cargo generate-lockfile + - name: auto commit + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "[skip ci] updating app version to ${{ steps.version-bump.outputs.new_tag }}" + branch: update-from-${{ github.sha }} + # create PR using GitHub CLI + - name: create PR with update info + id: create-pr + run: gh pr create --base rolling --head update-from-${{ github.sha }} --title 'Merge new update into rolling' --body 'Created by Github action' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # merge PR using GitHub CLI + - name: merge PR with update info + id: merge-pr + run: gh pr merge --admin --merge --subject 'Merge update info' --delete-branch + env: + GH_TOKEN: ${{ secrets.ADMIN_RIGHTS_TOKEN }} + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + generate_release_notes: true + name: ${{ steps.version-bump.outputs.new_tag }} + tag_name: ${{ steps.version-bump.outputs.new_tag }} + prerelease: false + env: + GITHUB_REPOSITORY: ${{ github.repository }} \ No newline at end of file