From 62c7d061038b7924115ea2f807f9c231fe34f24d Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Fri, 13 Mar 2020 12:53:20 +0100 Subject: [PATCH] .github: add Github actions for virtual/rust Whenever a new upstream Rust release appears, a Github workflow in `coreos-overlay` creates a new pull request for `dev-lang/rust`. At the same time, it sends a repository dispatch event to portage-stable, so it also creates a pull request for `virtual/rust`. --- .../.github/workflows/rust-apply-patch.sh | 13 +++++++ .../workflows/rust-pull-request-alpha.yml | 37 +++++++++++++++++++ .../workflows/rust-pull-request-edge.yml | 37 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100755 sdk_container/src/third_party/portage-stable/.github/workflows/rust-apply-patch.sh create mode 100644 sdk_container/src/third_party/portage-stable/.github/workflows/rust-pull-request-alpha.yml create mode 100644 sdk_container/src/third_party/portage-stable/.github/workflows/rust-pull-request-edge.yml diff --git a/sdk_container/src/third_party/portage-stable/.github/workflows/rust-apply-patch.sh b/sdk_container/src/third_party/portage-stable/.github/workflows/rust-apply-patch.sh new file mode 100755 index 0000000000..754462d6ac --- /dev/null +++ b/sdk_container/src/third_party/portage-stable/.github/workflows/rust-apply-patch.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -euo pipefail + +git fetch origin +git checkout -B "${BASE_BRANCH}" "origin/${BASE_BRANCH}" + +pushd "virtual/rust" >/dev/null || exit +VERSION_OLD=$(ls -1 rust-*.ebuild | sed -n "s/rust-\(1.[0-9]*.[0-9]*\).ebuild/\1/p" | sort -ruV | head -n1) +git mv rust-${VERSION_OLD}.ebuild "rust-${VERSION_NEW}.ebuild" +popd >/dev/null || exit + +echo ::set-output name=VERSION_OLD::"${VERSION_OLD}" diff --git a/sdk_container/src/third_party/portage-stable/.github/workflows/rust-pull-request-alpha.yml b/sdk_container/src/third_party/portage-stable/.github/workflows/rust-pull-request-alpha.yml new file mode 100644 index 0000000000..b42c3ff1e2 --- /dev/null +++ b/sdk_container/src/third_party/portage-stable/.github/workflows/rust-pull-request-alpha.yml @@ -0,0 +1,37 @@ +on: + repository_dispatch: + types: [cargo-pull-request-alpha] + +jobs: + flatcar-rust-prs: + runs-on: ubuntu-latest + env: + GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no" + steps: + - uses: actions/checkout@v2 + - name: Fetch latest Cargo release + id: fetch-latest-release + run: | + git clone --depth=1 --no-checkout https://github.com/rust-lang/rust + versionAlpha=$(git -C rust ls-remote --tags origin | cut -f2 | sed -n "/refs\/tags\/1.[0-9]*.[0-9]*$/s/^refs\/tags\///p" | sort -ruV | head -n1) + rm -rf rust + echo ::set-output name=VERSION_ALPHA::$(echo ${versionAlpha}) + echo ::set-output name=BASE_BRANCH_ALPHA::flatcar-master-alpha + - name: Apply patch for Alpha + id: apply-patch-alpha + env: + BASE_BRANCH: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_ALPHA }} + VERSION_NEW: ${{ steps.fetch-latest-release.outputs.VERSION_ALPHA }} + run: .github/workflows/rust-apply-patch.sh + - name: Create pull request for Alpha + uses: peter-evans/create-pull-request@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + base: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_ALPHA }} + branch: rust-${{ steps.fetch-latest-release.outputs.VERSION_ALPHA }}-alpha + author: Flatcar Buildbot + committer: Flatcar Buildbot + title: Upgrade Cargo in Alpha from ${{ steps.apply-patch-alpha.outputs.VERSION_OLD }} to ${{ steps.fetch-latest-release.outputs.VERSION_ALPHA }} + commit-message: Upgrade Cargo in Alpha from ${{ steps.apply-patch-alpha.outputs.VERSION_OLD }} to ${{ steps.fetch-latest-release.outputs.VERSION_ALPHA }} + body: Upgrade Cargo in Alpha from ${{ steps.apply-patch-alpha.outputs.VERSION_OLD }} to ${{ steps.fetch-latest-release.outputs.VERSION_ALPHA }} + labels: alpha diff --git a/sdk_container/src/third_party/portage-stable/.github/workflows/rust-pull-request-edge.yml b/sdk_container/src/third_party/portage-stable/.github/workflows/rust-pull-request-edge.yml new file mode 100644 index 0000000000..372ab64893 --- /dev/null +++ b/sdk_container/src/third_party/portage-stable/.github/workflows/rust-pull-request-edge.yml @@ -0,0 +1,37 @@ +on: + repository_dispatch: + types: [cargo-pull-request-edge] + +jobs: + flatcar-rust-prs: + runs-on: ubuntu-latest + env: + GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no" + steps: + - uses: actions/checkout@v2 + - name: Fetch latest Cargo release + id: fetch-latest-release + run: | + git clone --depth=1 --no-checkout https://github.com/rust-lang/rust + versionEdge=$(git -C rust ls-remote --tags origin | cut -f2 | sed -n "/refs\/tags\/1.[0-9]*.[0-9]*$/s/^refs\/tags\///p" | sort -ruV | head -n1) + rm -rf rust + echo ::set-output name=VERSION_EDGE::$(echo ${versionEdge}) + echo ::set-output name=BASE_BRANCH_EDGE::flatcar-master-edge + - name: Apply patch for Edge + id: apply-patch-edge + env: + BASE_BRANCH: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_EDGE }} + VERSION_NEW: ${{ steps.fetch-latest-release.outputs.VERSION_EDGE }} + run: .github/workflows/rust-apply-patch.sh + - name: Create pull request for Edge + uses: peter-evans/create-pull-request@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + base: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_EDGE }} + branch: rust-${{ steps.fetch-latest-release.outputs.VERSION_EDGE }}-edge + author: Flatcar Buildbot + committer: Flatcar Buildbot + title: Upgrade Cargo in Edge from ${{ steps.apply-patch-edge.outputs.VERSION_OLD }} to ${{ steps.fetch-latest-release.outputs.VERSION_EDGE }} + commit-message: Upgrade Cargo in Edge from ${{ steps.apply-patch-edge.outputs.VERSION_OLD }} to ${{ steps.fetch-latest-release.outputs.VERSION_EDGE }} + body: Upgrade Cargo in Edge from ${{ steps.apply-patch-edge.outputs.VERSION_OLD }} to ${{ steps.fetch-latest-release.outputs.VERSION_EDGE }} + labels: edge