因为写成 echo "nvcmp=$(...)" 时退出码来自 echo,管道里任一环失败都会被吞掉, 只留下空的 nvcmp= 到展开 matrix 时才暴露,所以把赋值单独一行,配合 set -o pipefail 在失败处直接中止。 Signed-off-by: Zakk <zakk@gentoozh.org>
183 lines
5.7 KiB
YAML
183 lines
5.7 KiB
YAML
name: nvchecker
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
# * is a special character in YAML so you have to quote this string
|
|
# UTC 09:00 -> CST (China) 17:00, see https://datetime360.com/cn/utc-cst-china-time/
|
|
- cron: '0 09 * * *'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
eix:
|
|
if: github.repository == 'gentoo-zh/overlay'
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: gentoo/stage3
|
|
options: --privileged
|
|
outputs:
|
|
pkgs: ${{ steps.eix.outputs.pkgs }}
|
|
steps:
|
|
- name: sync gentoo main tree
|
|
run: |
|
|
emerge-webrsync --no-pgp-verify
|
|
|
|
- name: cat binrepos
|
|
run: |
|
|
cat /etc/portage/binrepos.conf/*
|
|
|
|
- name: setup features
|
|
run: |
|
|
echo 'FEATURES="getbinpkg"' >> /etc/portage/make.conf
|
|
getuto
|
|
|
|
- name: install depends
|
|
run: |
|
|
emerge --verbose --quiet --jobs $(nproc) --autounmask y --autounmask-continue y \
|
|
app-eselect/eselect-repository \
|
|
app-portage/eix \
|
|
dev-vcs/git
|
|
|
|
- name: setup gentoo git repo
|
|
run: |
|
|
eselect repository add gentoo git https://github.com/gentoo-mirror/gentoo.git
|
|
rm -rf /var/db/repos/gentoo
|
|
emaint sync -r gentoo
|
|
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: eix
|
|
id: eix
|
|
run: |
|
|
# eselect
|
|
echo "::group::eselect repository add and sync"
|
|
repo_name=$(cat profiles/repo_name)
|
|
eselect repository add "$repo_name" git "file://${PWD}"
|
|
emerge --sync "$repo_name"
|
|
egencache --jobs=$(nproc) --update --repo "$repo_name" &> /dev/null
|
|
eix-update
|
|
echo "::endgroup::"
|
|
# eix
|
|
echo "::group::eix search packages"
|
|
# availableversions minus live: bestversion picks 9999, which nothing upstream beats
|
|
pkgs=$(
|
|
ACCEPT_LICENSE="*" ACCEPT_KEYWORDS="~amd64 ~arm64 ~loong ~riscv" EIX_LIMIT=0 \
|
|
NONLIVE='{first}{!*nv}{}{!plainversion=9999}{!ishardmasked}{isstable}{*nv=<version>}{}{}{}{last}{$nv}<category>/<name>-<$nv>\n{}{}' \
|
|
eix --pure-packages --in-overlay "$repo_name" --format '<availableversions:NONLIVE>'
|
|
)
|
|
pkgs=$(qatom -F "\"%{CATEGORY}/%{PN}\": \"%{PV}\"," $pkgs) # remove revision
|
|
pkgs="{ ${pkgs::-1} }"
|
|
echo $pkgs
|
|
# use multiine string:
|
|
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-an-output-parameter
|
|
{
|
|
echo 'pkgs<<EOF'
|
|
echo "$pkgs"
|
|
echo 'EOF'
|
|
} >> "$GITHUB_OUTPUT"
|
|
echo "::endgroup::"
|
|
|
|
nvchecker:
|
|
needs: eix
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
nvcmp: ${{ steps.nvchecker.outputs.nvcmp }}
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: install depends
|
|
run: |
|
|
pip install nvchecker jq
|
|
|
|
- name: echo pkgs
|
|
run: |
|
|
echo '${{ needs.eix.outputs.pkgs }}'
|
|
|
|
- name: nvchecker
|
|
id: nvchecker
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GENTOO_ZH_NVCHECKER_PAT }}
|
|
run: |
|
|
echo "::group::nvchecker"
|
|
cd .github/workflows/
|
|
echo '${{ needs.eix.outputs.pkgs }}' > old_ver.json
|
|
echo -e "[keys]\ngithub = \"${{ secrets.GITHUB_TOKEN }}\"" > keyfile.toml
|
|
nvchecker --file overlay.toml --keyfile keyfile.toml
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::nvcmp"
|
|
# assign on its own line: inside echo "$(...)" the exit status is echo's,
|
|
# so a failing pipe would go unnoticed until the matrix expands
|
|
set -o pipefail
|
|
nvcmp=$(nvcmp --file overlay.toml --json --newer \
|
|
| jq 'map({name, newver, oldver})' | jq -c .)
|
|
echo "nvcmp=${nvcmp}" >> $GITHUB_OUTPUT
|
|
echo "::endgroup::"
|
|
|
|
issues-bumper:
|
|
needs: nvchecker
|
|
if: needs.nvchecker.outputs.nvcmp != '[]'
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
include: ${{ fromJson(needs.nvchecker.outputs.nvcmp) }}
|
|
steps:
|
|
- name: Checkout bumpbot
|
|
uses: actions/checkout@v7
|
|
with:
|
|
repository: 'gentoo-zh-drafts/bumpbot'
|
|
|
|
- name: Checkout gentoo-zh
|
|
uses: actions/checkout@v7
|
|
with:
|
|
path: 'gentoo-zh'
|
|
|
|
- name: update issues
|
|
timeout-minutes: 1
|
|
env:
|
|
name: ${{ matrix.name }}
|
|
newver: ${{ matrix.newver }}
|
|
oldver: ${{ matrix.oldver }}
|
|
GITHUB_TOKEN: ${{ secrets.GENTOO_ZH_NVCHECKER_PAT }} # https://github.com/gentoo-zh/overlay/pull/3130
|
|
run: |
|
|
go run . --file gentoo-zh/.github/workflows/overlay.toml --name "$name" --newver "$newver" --oldver "$oldver"
|
|
|
|
# For packages whose vendor/deps bundle is generated on demand (see
|
|
# gentoo-zh/deps-dispatcher/config.toml), fire the gentoo-deps generator
|
|
# as soon as a new version is detected, so the bundle is ready before autobump.
|
|
deps-dispatch:
|
|
needs: nvchecker
|
|
if: needs.nvchecker.outputs.nvcmp != '[]'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout deps-dispatcher
|
|
uses: actions/checkout@v7
|
|
with:
|
|
repository: 'gentoo-zh/deps-dispatcher'
|
|
|
|
- name: Checkout gentoo-zh
|
|
uses: actions/checkout@v7
|
|
with:
|
|
path: 'gentoo-zh'
|
|
|
|
- name: Get a token that can dispatch gentoo-deps
|
|
uses: actions/create-github-app-token@v3
|
|
id: app-token
|
|
with:
|
|
client-id: ${{ secrets.DRAFTS_BOT_CLIENT_ID }}
|
|
private-key: ${{ secrets.DRAFTS_BOT_PRIVATE_KEY }}
|
|
owner: gentoo-zh
|
|
repositories: gentoo-deps
|
|
|
|
- name: Dispatch generators for new versions
|
|
timeout-minutes: 5
|
|
env:
|
|
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
NVCMP: ${{ needs.nvchecker.outputs.nvcmp }}
|
|
run: echo "$NVCMP" | python3 dispatch.py --config gentoo-zh/.github/workflows/gentoo-deps-dispatcher.toml --run
|