Skip to content

Update Elixir Patch Versions for Bazel Based Workflows #510

Update Elixir Patch Versions for Bazel Based Workflows

Update Elixir Patch Versions for Bazel Based Workflows #510

name: Update Elixir Patch Versions for Bazel Based Workflows
on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:
jobs:
update-toolchains:
name: Update Elixir Versions
runs-on: ubuntu-20.04
strategy:
max-parallel: 1
fail-fast: false
matrix:
include:
- elixir_version: "1.13"
name: '1_13'
- elixir_version: "1.14"
name: '1_14'
- elixir_version: "1.15"
name: '1_15'
timeout-minutes: 10
env:
branch: bump-elixir-${{ matrix.elixir_version }}
steps:
- name: CHECKOUT REPOSITORY
uses: actions/checkout@v4
- name: FAIL IF THE PR ALREADY EXISTS
id: check-for-branch
run: |
set +e
if git ls-remote --exit-code --heads origin ${{ env.branch }}; then
echo "Branch ${{ env.branch }} already exits"
exit 1
fi
- name: DETERMINE LATEST PATCH & SHA
id: fetch-version
run: |
TAG_NAME=$(curl -s GET https://api.github.com/repos/elixir-lang/elixir/tags?per_page=100 \
| jq -r 'map(select(.name | contains("v${{ matrix.elixir_version }}"))) | first | .name')
if [[ -z "${TAG_NAME}" ]]; then
echo "Failed to determine latest TAG_NAME for v${{ matrix.elixir_version }}"
exit 1
fi
ARCHIVE_URL="https://github.com/elixir-lang/elixir/archive/${TAG_NAME}.tar.gz"
wget --continue --quiet --output-document="/tmp/elixir.tar.gz" "${ARCHIVE_URL}" && \
SHA="$(shasum -a 256 "/tmp/elixir.tar.gz" | awk '{print $1}')"
if [[ -z "${SHA}" ]]; then
echo "Failed to determine SHA for ${TAG_NAME}"
exit 1
fi
echo "VERSION=${TAG_NAME#v}" >> $GITHUB_OUTPUT
echo "SHA=${SHA}" >> $GITHUB_OUTPUT
- name: MODIFY VERSION FILE
run: |
sudo npm install --global --silent @bazel/buildozer
OLD_SHA="$(cat MODULE.bazel | buildozer 'print sha256' -:${{ matrix.name }})"
OLD_VERSION="$(cat MODULE.bazel | buildozer 'print version' -:${{ matrix.name }})"
echo "OLD_SHA: $OLD_SHA"
echo "OLD_VERSION: $OLD_VERSION"
echo "$(cat MODULE.bazel | buildozer 'set sha256 "${{ steps.fetch-version.outputs.SHA }}"' -:${{ matrix.name }})" > MODULE.bazel
echo "$(cat MODULE.bazel | buildozer 'set version "${{ steps.fetch-version.outputs.VERSION }}"' -:${{ matrix.name }})" > MODULE.bazel
echo "MODULE.bazel updated"
set -x
git diff
- name: CREATE PULL REQUEST
uses: peter-evans/[email protected]
with:
token: ${{ secrets.REPO_SCOPED_TOKEN }}
committer: GitHub <[email protected]>
author: GitHub <[email protected]>
title: Adopt elixir ${{ steps.fetch-version.outputs.VERSION }}
body: >
Automated changes created by
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
using the [create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action in the ${{ github.workflow }} workflow.
commit-message: |
Adopt elixir ${{ steps.fetch-version.outputs.VERSION }}
labels: |
backport-v3.12.x
backport-v3.11.x
backport-v3.10.x
branch: ${{ env.branch }}
delete-branch: true