diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad82c559f..d6ee6c9e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,22 +32,11 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} - - name: "Update version number" + - name: "Read version number" run: | - VERSION="$(python -c "print('%04d' % int('${{ github.event.pull_request.title }}'.removeprefix('V').removesuffix(' Release Candidate Changes')), end='')")" - DATE="$(python -c "from datetime import date;print(date.today().strftime('%d%m%Y'), end='')")" - RELEASE_NAME="XFW-${VERSION}" - RELEASE_TAG="${RELEASE_NAME}_${DATE}" + RELEASE_TAG="$(grep -o "DIST_SUFFIX = .*" fbt_options.py | cut -d'"' -f2)" echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV - sed "s/VERSION = \"XFW-[[:digit:]]\{4\}\"/VERSION = \"${RELEASE_NAME}\"/g" scripts/version.py > scripts/version.py.new - rm scripts/version.py - mv scripts/version.py.new scripts/version.py - - sed "s/DIST_SUFFIX = \"XFW-[[:digit:]]\{4\}_[[:digit:]]\{8\}\"/DIST_SUFFIX = \"${RELEASE_TAG}\"/g" fbt_options.py > fbt_options.py.new - rm fbt_options.py - mv fbt_options.py.new fbt_options.py - - name: 'Build the firmware' run: | set -e @@ -72,60 +61,6 @@ jobs: run: | python -c "import json, os;f = '.github/workflow_data/release.md';c = json.load(open(os.environ['GITHUB_EVENT_PATH']))['pull_request']['body'];f_ = open(f);n = f_.read().format(release_tag='${RELEASE_TAG}', webupdater_url='${WEBUPDATER_URL}', changelog=c);f_.close();f_ = open(f, 'w');f_.write(n);f_.close()" - - name: "Commit new version number" - uses: EndBug/add-and-commit@v9 - id: commit - with: - default_author: github_actions - message: Update version number - add: 'fbt_options.py scripts/version.py' - - - name: "Wait for checks to pass" - run: | - pushed=${{ steps.commit.outputs.pushed }} - echo "Commit was pushed: ${pushed}" - $pushed - - sha="${{ steps.commit.outputs.commit_long_sha }}" - echo "Pushed commit sha: ${sha}" - - echo "Waiting for PR head to sync" - while [ "$new" != "$sha" ]; do - sleep 1 - new="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.base.repo.full_name }}/pulls/${{ github.event.pull_request.number }}" | jq -r ".head.sha")" - echo "New PR head sha: ${new}" - done - echo "PR synced" - - echo "Finding required status checks" - checks="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.base.repo.full_name }}/branches/${{ github.event.pull_request.base.ref }}" | jq -r ".protection.required_status_checks.contexts[]")" - for check in $checks; do - echo "Started waiting for check: ${check}" - found=false - while ! $found; do - sleep 1 - echo "Querying check suites" - suites="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.head.repo.full_name }}/commits/${sha}/check-suites" | jq -r ".check_suites[].id")" - for suite in $suites; do - completed=false - while ! $completed; do - sleep 1 - echo "Querying check suite: ${suite}" - run="$(curl -s "https://api.github.com/repos/${{ github.event.pull_request.head.repo.full_name }}/check-suites/${suite}/check-runs" | jq -r '.check_runs[] | select(.name == "${check}")')" - [ "$run" != "" ] || (echo "Check suite ${suite} does not match check: ${check}" && continue 2) - found=true - [ "$(echo "$run" | jq -r ".status")" = "completed" ] || (echo "Check suite ${suite} not complete yet" && sleep 10 && continue) - completed=true - echo "Check suite ${suite} completed" - [ "$(echo "$run" | jq -r ".conclusion")" = "success" ] || (echo "Check failed: ${check}" && false) - echo "Check passed: ${check}" - continue 3 - done - done - done - done - - - name: "Merge pull request" uses: "pascalgn/automerge-action@v0.15.6" env: