.github: replace COMMIT_ID in runc ebuilds

So far Github actions have not changed existing `COMMIT_ID` variable in
runc ebuilds. As a result, the result PRs have correct versions with wrong
commit hashes.

We need to replace `COMMIT_ID` with one that matches with the new version.
To do that, clone the repo completely, since it is not possible to get
the commit hash by running `git rev-parse` on a shallow cloned repo.
Parse commit from a tag with an original version with `-` as its
delimiter, e.g. `v1.0.0-rc91`, because a transformed
tag like `v1.0.0_rc91` does not exist in the upstream repo.
This commit is contained in:
Dongsu Park 2020-07-02 15:15:00 +02:00 committed by Kai Lüke
parent 39b5c5d2e0
commit bb6a5945f4
3 changed files with 13 additions and 4 deletions

View File

@ -27,6 +27,7 @@ runcEbuildOld=$(ls -1 app-emulation/docker-runc/docker-runc-${VERSION_OLD}*.ebui
runcEbuildNew="app-emulation/docker-runc/docker-runc-${VERSION_NEW}.ebuild" runcEbuildNew="app-emulation/docker-runc/docker-runc-${VERSION_NEW}.ebuild"
git mv ${runcEbuildOld} ${runcEbuildNew} git mv ${runcEbuildOld} ${runcEbuildNew}
sed -i "s/${VERSION_OLD}/${VERSION_NEW}/g" ${runcEbuildNew} sed -i "s/${VERSION_OLD}/${VERSION_NEW}/g" ${runcEbuildNew}
sed -i "s/COMMIT_ID=\"\(.*\)\"/COMMIT_ID=\"${COMMIT_HASH}\"/g" ${runcEbuildNew}
# docker-runc ebuild file has also lines of runc versions with '-' instead of '_', e.g. '1.0.0-rc10' # docker-runc ebuild file has also lines of runc versions with '-' instead of '_', e.g. '1.0.0-rc10'
VERSION_OLD_HYPHEN=${VERSION_OLD//_/-} VERSION_OLD_HYPHEN=${VERSION_OLD//_/-}

View File

@ -13,13 +13,16 @@ jobs:
- name: Fetch latest Runc release - name: Fetch latest Runc release
id: fetch-latest-release id: fetch-latest-release
run: | run: |
git clone --depth=1 --no-checkout https://github.com/opencontainers/runc git clone https://github.com/opencontainers/runc
# Get the newest runc version, including official releases and rc versions. # Get the newest runc version, including official releases and rc versions.
# We need some sed tweaks like adding underscore, sort, and trim the underscore again, # We need some sed tweaks like adding underscore, sort, and trim the underscore again,
# so that sort -V can give the newest version including non-rc versions. # so that sort -V can give the newest version including non-rc versions.
versionAlpha=$(git -C runc ls-remote --tags origin | cut -f2 | sed '/-/!{s/$/_/}' | sed -n "/refs\/tags\/v[0-9]*.[0-9]*.[0-9]*/s/^refs\/tags\/v//p" |grep -v '\{\}$' | sort -ruV | sed 's/_$//' | head -n1 | tr '-' '_') versionAlpha=$(git -C runc ls-remote --tags origin | cut -f2 | sed '/-/!{s/$/_/}' | sed -n "/refs\/tags\/v[0-9]*.[0-9]*.[0-9]*/s/^refs\/tags\/v//p" |grep -v '\{\}$' | sort -ruV | sed 's/_$//' | head -n1)
commitAlpha="$(git -C runc rev-parse v${versionAlpha})"
versionAlpha="${versionAlpha//-/_}"
rm -rf runc rm -rf runc
echo ::set-output name=VERSION_ALPHA::$(echo ${versionAlpha}) echo ::set-output name=VERSION_ALPHA::$(echo ${versionAlpha})
echo ::set-output name=COMMIT_ALPHA::$(echo ${commitAlpha})
echo ::set-output name=BASE_BRANCH_ALPHA::flatcar-master-alpha echo ::set-output name=BASE_BRANCH_ALPHA::flatcar-master-alpha
- name: Set up Flatcar SDK - name: Set up Flatcar SDK
id: setup-flatcar-sdk id: setup-flatcar-sdk
@ -30,6 +33,7 @@ jobs:
CHANNEL: alpha CHANNEL: alpha
BASE_BRANCH: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_ALPHA }} BASE_BRANCH: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_ALPHA }}
VERSION_NEW: ${{ steps.fetch-latest-release.outputs.VERSION_ALPHA }} VERSION_NEW: ${{ steps.fetch-latest-release.outputs.VERSION_ALPHA }}
COMMIT_HASH: ${{ steps.fetch-latest-release.outputs.COMMIT_ALPHA }}
PATH: ${{ steps.setup-flatcar-sdk.outputs.path }} PATH: ${{ steps.setup-flatcar-sdk.outputs.path }}
run: .github/workflows/runc-apply-patch.sh run: .github/workflows/runc-apply-patch.sh
- name: Create pull request for Alpha - name: Create pull request for Alpha

View File

@ -13,13 +13,16 @@ jobs:
- name: Fetch latest Runc release - name: Fetch latest Runc release
id: fetch-latest-release id: fetch-latest-release
run: | run: |
git clone --depth=1 --no-checkout https://github.com/opencontainers/runc git clone https://github.com/opencontainers/runc
# Get the newest runc version, including official releases and rc versions. # Get the newest runc version, including official releases and rc versions.
# We need some sed tweaks like adding underscore, sort, and trim the underscore again, # We need some sed tweaks like adding underscore, sort, and trim the underscore again,
# so that sort -V can give the newest version including non-rc versions. # so that sort -V can give the newest version including non-rc versions.
versionEdge=$(git -C runc ls-remote --tags origin | cut -f2 | sed '/-/!{s/$/_/}' | sed -n "/refs\/tags\/v[0-9]*.[0-9]*.[0-9]*/s/^refs\/tags\/v//p" |grep -v '\{\}$' | sort -ruV | sed 's/_$//' | head -n1 | tr '-' '_') versionEdge=$(git -C runc ls-remote --tags origin | cut -f2 | sed '/-/!{s/$/_/}' | sed -n "/refs\/tags\/v[0-9]*.[0-9]*.[0-9]*/s/^refs\/tags\/v//p" |grep -v '\{\}$' | sort -ruV | sed 's/_$//' | head -n1)
commitEdge="$(git -C runc rev-parse v${versionEdge})"
versionEdge="${versionEdge//-/_}"
rm -rf runc rm -rf runc
echo ::set-output name=VERSION_EDGE::$(echo ${versionEdge}) echo ::set-output name=VERSION_EDGE::$(echo ${versionEdge})
echo ::set-output name=COMMIT_EDGE::$(echo ${commitEdge})
echo ::set-output name=BASE_BRANCH_EDGE::flatcar-master-edge echo ::set-output name=BASE_BRANCH_EDGE::flatcar-master-edge
- name: Set up Flatcar SDK - name: Set up Flatcar SDK
id: setup-flatcar-sdk id: setup-flatcar-sdk
@ -30,6 +33,7 @@ jobs:
CHANNEL: edge CHANNEL: edge
BASE_BRANCH: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_EDGE }} BASE_BRANCH: ${{ steps.fetch-latest-release.outputs.BASE_BRANCH_EDGE }}
VERSION_NEW: ${{ steps.fetch-latest-release.outputs.VERSION_EDGE }} VERSION_NEW: ${{ steps.fetch-latest-release.outputs.VERSION_EDGE }}
COMMIT_HASH: ${{ steps.fetch-latest-release.outputs.COMMIT_EDGE }}
PATH: ${{ steps.setup-flatcar-sdk.outputs.path }} PATH: ${{ steps.setup-flatcar-sdk.outputs.path }}
run: .github/workflows/runc-apply-patch.sh run: .github/workflows/runc-apply-patch.sh
- name: Create pull request for Edge - name: Create pull request for Edge