Auto Update #2531
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto Update | |
| on: | |
| schedule: | |
| - cron: '0 */12 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| check: | |
| name: Check | |
| runs-on: ubuntu-latest | |
| outputs: | |
| latest_version: ${{ steps.latest_version.outputs.latest_version }} | |
| latest_version_formatted: ${{ steps.latest_version.outputs.latest_version_formatted }} | |
| manifest_version: ${{ steps.manifest_version.outputs.manifest_version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Retrieve latest version | |
| id: latest_version | |
| run: | | |
| latest_version="$(wget -q https://gitweb.torproject.org/tor.git/plain/ChangeLog -O - | grep -E -m10 '^Changes in version\s[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\s' | sed 's/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*$/\1/' | sort -rV | head -n 1)" | |
| latest_version_formatted=$(echo ${latest_version} | sed 's/\(.*\)\./\1-rc/') | |
| echo "latest_version=${latest_version}" >> $GITHUB_OUTPUT | |
| echo "latest_version_formatted=${latest_version_formatted}" >> $GITHUB_OUTPUT | |
| - name: Retrieve version from manifest | |
| id: manifest_version | |
| run: | | |
| manifest_version="$(jq -r '.[0].version' versions-manifest.json)" | |
| echo "manifest_version=${manifest_version}" >> $GITHUB_OUTPUT | |
| - name: Output latest versions | |
| run: | | |
| echo "The latest version of Tor on the website is: ${{ steps.latest_version.outputs.latest_version_formatted }} (${{ steps.latest_version.outputs.latest_version }})" | |
| echo "The latest version of Tor in the manifest is: ${{ steps.manifest_version.outputs.manifest_version }}" | |
| update-build-scripts: | |
| name: Update Build Scripts | |
| runs-on: ubuntu-latest | |
| needs: ['check'] | |
| outputs: | |
| pull_request_url: ${{ steps.create_pull_request.outputs.pull-request-url }} | |
| if: ${{ needs.check.outputs.latest_version_formatted != needs.check.outputs.manifest_version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: tor-actions/tor-build-scripts | |
| ref: master | |
| - name: Get SHA256 checksum | |
| id: checksum | |
| run: | | |
| checksum=$(curl https://dist.torproject.org/tor-${{ needs.check.outputs.latest_version }}.tar.gz.sha256sum) | |
| checksum=$(echo "${checksum}" | grep -oE "[a-f0-9]{64}") | |
| echo "checksum=${checksum}" >> $GITHUB_OUTPUT | |
| - name: Update `env.sh` file | |
| run: | | |
| env_file_contents="$(cat env.sh)" | |
| env_file_contents="$(echo "${env_file_contents}" | sed -e 's#export TOR_VERSION="[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"#export TOR_VERSION=\"${{ needs.check.outputs.latest_version }}\"#g')" | |
| env_file_contents="$(echo "${env_file_contents}" | sed -E 's#export TOR_HASH="[a-f0-9]{64}"#export TOR_HASH=\"${{ steps.checksum.outputs.checksum }}\"#g')" | |
| echo "${env_file_contents}" > env.sh | |
| - name: Create PR for latest version | |
| id: create_pull_request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.TOC_ACTION_ACCESS_REPO }} | |
| commit-message: "release: add version v${{ needs.check.outputs.latest_version }}" | |
| committer: GitHub Action <noreply@github.com> | |
| title: "release: add version v${{ needs.check.outputs.latest_version }}" | |
| body: | | |
| This updates from ${{ needs.check.outputs.manifest_version }} to ${{ needs.check.outputs.latest_version }}. | |
| - [Changelog](https://gitweb.torproject.org/tor.git/plain/ChangeLog?h=tor-${{ needs.check.outputs.latest_version }}) | |
| - [Tag](https://gitweb.torproject.org/tor.git/tag/?h=tor-${{ needs.check.outputs.latest_version }}) | |
| branch: release/newver-${{ needs.check.outputs.latest_version }} | |
| update: | |
| name: Update | |
| runs-on: ubuntu-latest | |
| needs: ['check', 'update-build-scripts'] | |
| if: ${{ needs.check.outputs.latest_version_formatted != needs.check.outputs.manifest_version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Generate new version manifest | |
| id: new_version_manifest | |
| run: | | |
| new_version_manifest="$(cat versions-manifest.tmpl | sed -e 's#0.0.0.0#${{ needs.check.outputs.latest_version }}#g' | sed -e 's#0.0.0-rc0#${{ needs.check.outputs.latest_version_formatted }}#g' | jq -c)" | |
| echo "::set-output name=new_version_manifest::${new_version_manifest}" | |
| - name: Update manifest | |
| run: | | |
| cp versions-manifest.json versions-manifest.json.bak | |
| jq --argjson manifest '${{ steps.new_version_manifest.outputs.new_version_manifest }}' '. |= [$manifest] + .' versions-manifest.json.bak | tee versions-manifest.json | |
| rm versions-manifest.json.bak | |
| - name: Create PR for latest version | |
| id: create_pull_request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| commit-message: "release: add version v${{ needs.check.outputs.latest_version }}" | |
| committer: GitHub Action <noreply@github.com> | |
| title: "release: add version v${{ needs.check.outputs.latest_version }} (${{ needs.check.outputs.latest_version_formatted }})" | |
| body: | | |
| This should be merged after: ${{ needs.update-build-scripts.outputs.pull_request_url }} | |
| This updates from ${{ needs.check.outputs.manifest_version }} to ${{ needs.check.outputs.latest_version_formatted }}. | |
| - [Changelog](https://gitweb.torproject.org/tor.git/plain/ChangeLog?h=tor-${{ needs.check.outputs.latest_version }}) | |
| - [Tag](https://gitweb.torproject.org/tor.git/tag/?h=tor-${{ needs.check.outputs.latest_version }}) | |
| branch: release/newver-${{ needs.check.outputs.latest_version_formatted }} | |
| logging: | |
| name: Logging | |
| runs-on: ubuntu-latest | |
| needs: ['check'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Write log | |
| run: | | |
| git switch --orphan logging | |
| git config --local user.email "github-action@users.noreply.github.com" | |
| git config --local user.name "GitHub Action" | |
| git commit --allow-empty -m "Commit on orphan branch at $(TZ=UTC date +'%Y/%m/%d')" | |
| git push --force -u origin logging |