diff --git a/.github/packages/libcurl-julia-bin/version.txt b/.github/packages/libcurl-julia-bin/version.txt new file mode 100644 index 0000000..cec9124 --- /dev/null +++ b/.github/packages/libcurl-julia-bin/version.txt @@ -0,0 +1 @@ +libcurl-julia-bin-v1.10-1 diff --git a/.github/packages/nsis/version.txt b/.github/packages/nsis/version.txt new file mode 100644 index 0000000..bb5d7d0 --- /dev/null +++ b/.github/packages/nsis/version.txt @@ -0,0 +1 @@ +nsis-v3.09-1 diff --git a/.github/workflows/make-libcurl-julia-bin.yml b/.github/workflows/make-libcurl-julia-bin.yml index 801072e..e550a7f 100644 --- a/.github/workflows/make-libcurl-julia-bin.yml +++ b/.github/workflows/make-libcurl-julia-bin.yml @@ -2,24 +2,26 @@ on: workflow_dispatch: ~ push: branches: - - "libcurl-julia-bin" + - "master" + paths: + - ".github/packages/libcurl-julia-bin/version.txt" jobs: makepkg: container: archlinux:base-devel runs-on: ubuntu-latest steps: + - run: pacman-key --init + - run: pacman -Syu --noconfirm dbus-daemon-units git github-cli - uses: actions/checkout@v4 with: persist-credentials: false path: libcurl-julia-bin ref: libcurl-julia-bin - - run: pacman-key --init - - run: pacman -Syu --noconfirm dbus-daemon-units - run: |- makepkg -V - echo 'PACKAGER="Heptazhou "' >> /etc/makepkg.conf sed -re 's/\b(EUID) == 0\b/\1 < -0/g' -i /bin/makepkg + sed -re 's/^#?(PACKAGER).*$/\1="Heptazhou "/g' -i /etc/makepkg.conf - run: |- cd libcurl-julia-bin makepkg -si --noconfirm @@ -29,3 +31,7 @@ jobs: with: compression-level: 0 path: "*.pkg.tar.zst" + - run: gh release create -p --target libcurl-julia-bin libcurl-julia-bin-v1.10-1 *.pkg.tar.zst + env: + GH_REPO: ${{ env.GITHUB_REPOSITORY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/make-nsis.yml b/.github/workflows/make-nsis.yml index be85e60..ec3c52f 100644 --- a/.github/workflows/make-nsis.yml +++ b/.github/workflows/make-nsis.yml @@ -2,13 +2,17 @@ on: workflow_dispatch: ~ push: branches: - - "nsis" + - "master" + paths: + - ".github/packages/nsis/version.txt" jobs: makepkg: container: archlinux:base-devel runs-on: ubuntu-latest steps: + - run: pacman-key --init + - run: pacman -Syu --noconfirm dbus-daemon-units git github-cli - uses: actions/checkout@v4 with: persist-credentials: false @@ -19,12 +23,10 @@ jobs: persist-credentials: false path: nsis ref: nsis - - run: pacman-key --init - - run: pacman -Syu --noconfirm dbus-daemon-units - run: |- makepkg -V - echo 'PACKAGER="Heptazhou "' >> /etc/makepkg.conf sed -re 's/\b(EUID) == 0\b/\1 < -0/g' -i /bin/makepkg + sed -re 's/^#?(PACKAGER).*$/\1="Heptazhou "/g' -i /etc/makepkg.conf - run: |- cd mingw-w64-zlib makepkg -si --noconfirm @@ -38,3 +40,7 @@ jobs: with: compression-level: 0 path: "*.pkg.tar.zst" + - run: gh release create -p --target nsis nsis-v3.09-1 *.pkg.tar.zst + env: + GH_REPO: ${{ env.GITHUB_REPOSITORY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/workflows.jl b/workflows.jl index d91d61b..54e0e3e 100644 --- a/workflows.jl +++ b/workflows.jl @@ -16,6 +16,7 @@ using OrderedCollections: OrderedDict as ODict using YAML: YAML, yaml +const PACKAGER = "Heptazhou " const YAML.yaml(xs...) = join(map(yaml, xs), "\n") macro S_str(string) :(Symbol($string)) @@ -33,43 +34,75 @@ const ACT_CHECKOUT(xs::Pair...) = ODict( S"uses" => S"actions/checkout@v4", S"with" => ODict(S"persist-credentials" => false, xs...), ) +const ACT_GH(cmd::String) = ODict( + S"run" => Symbol(cmd), + S"env" => ODict( + S"GH_REPO" => S"${{ env.GITHUB_REPOSITORY }}", + S"GH_TOKEN" => S"${{ secrets.GITHUB_TOKEN }}", + ), +) const ACT_SYNC(pkgbase::String) = ODict( S"uses" => S"repo-sync/github-sync@v2.3.0", S"with" => ODict( S"source_repo" => Symbol("https://aur.archlinux.org/$pkgbase.git"), S"source_branch" => S"master", - S"destination_branch" => Symbol("$pkgbase"), + S"destination_branch" => Symbol(pkgbase), S"github_token" => S"${{ secrets.PAT }}", ), ) + +const JOB_MAKE(pkgbases::Vector{String}, tag::String) = ODict( + S"container" => S"archlinux:base-devel", + S"runs-on" => S"ubuntu-latest", + S"steps" => [ + S"run" .=> [ + S"pacman-key --init" + S"pacman -Syu --noconfirm dbus-daemon-units git github-cli" + ] + ACT_CHECKOUT.(sort(pkgbases)) + S"run" .=> [ + """ + makepkg -V + sed -re 's/\\b(EUID) == 0\\b/\\1 < -0/g' -i /bin/makepkg + sed -re 's/^#?(PACKAGER).*\$/\\1="$PACKAGER"/g' \ + -i /etc/makepkg.conf""" + map(pkgbase -> strip(""" + cd $pkgbase + makepkg -si --noconfirm + mv -vt .. *.pkg.tar.zst + """), pkgbases) + S"ls -lav *.pkg.tar.zst" + ] + ACT_ARTIFACT("*.pkg.tar.zst") + ACT_GH("gh release create -p --target " * pkgbases[end] * + " $tag *.pkg.tar.zst") + ], +) const JOB_SYNC(pkgbase::String) = ODict( S"runs-on" => S"ubuntu-latest", S"steps" => [ACT_CHECKOUT(), ACT_SYNC(pkgbase)], ) -const MAKEPKG(pkgbases::Vector{String}) = ODict( - S"makepkg" => ODict( - S"container" => S"archlinux:base-devel", - S"runs-on" => S"ubuntu-latest", - S"steps" => [ - ACT_CHECKOUT.(sort(pkgbases)); - S"run" .=> [ - S"pacman-key --init" - S"pacman -Syu --noconfirm dbus-daemon-units" - """ - makepkg -V - echo 'PACKAGER="Heptazhou "' >> /etc/makepkg.conf - sed -re 's/$(s"\b(EUID) == 0\b/\1 < -0")/g' -i /bin/makepkg""" - map(pkgbase -> strip(""" - cd $pkgbase - makepkg -si --noconfirm - mv -vt .. *.pkg.tar.zst - """), pkgbases)... - S"ls -lav *.pkg.tar.zst" - ] - ACT_ARTIFACT("*.pkg.tar.zst") - ], - ), -) + +function makepkg(pkgbases::Vector{String}, v::String) + p = pkgbases[end] + f = ".github/packages/$p/version.txt" + mkpath(dirname(f)) + write(f, "$p-v$v", "\n") + write(".github/workflows/make-$p.yml", + yaml( + S"on" => ODict( + S"workflow_dispatch" => nothing, + S"push" => ODict( + S"branches" => ["master"], + S"paths" => [f], + ), + ), + S"jobs" => ODict( + S"makepkg" => JOB_MAKE(pkgbases, "$p-v$v"), + ), + ), + ) +end write(".github/workflows/repo-sync.yml", yaml( @@ -77,40 +110,22 @@ write(".github/workflows/repo-sync.yml", S"workflow_dispatch" => nothing, S"schedule" => [ODict(S"cron" => "0 */4 * * *")], ), - S"jobs" => ODict([ - Symbol(x) => JOB_SYNC(x) for x ∈ [ - "conda-zsh-completion" - "glibc-linux4" - "iraf-bin" - "libcurl-julia-bin" - "locale-mul_zz" - "mingw-w64-zlib" - "nsis" - "xgterm-bin" - ] + S"jobs" => ODict(Symbol(x) => JOB_SYNC(x) for x ∈ [ + "conda-zsh-completion" + "glibc-linux4" + "iraf-bin" + "libcurl-julia-bin" + "locale-mul_zz" + "mingw-w64-zlib" + "nsis" + "xgterm-bin" ]), ), ) # https://aur.archlinux.org/packages/libcurl-julia-bin -write(".github/workflows/make-libcurl-julia-bin.yml", - yaml( - S"on" => ODict( - S"workflow_dispatch" => nothing, - S"push" => ODict(S"branches" => ["libcurl-julia-bin"]), - ), - S"jobs" => MAKEPKG(["libcurl-julia-bin"]), - ), -) +makepkg(["libcurl-julia-bin"], "1.10-1") # https://aur.archlinux.org/packages/nsis -write(".github/workflows/make-nsis.yml", - yaml( - S"on" => ODict( - S"workflow_dispatch" => nothing, - S"push" => ODict(S"branches" => ["nsis"]), - ), - S"jobs" => MAKEPKG(["mingw-w64-zlib", "nsis"]), - ), -) +makepkg(["mingw-w64-zlib", "nsis"], "3.09-1")