From 020a43fd908d424909324658da6cacb17d5dd031 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 9 Sep 2024 19:24:23 -0400 Subject: [PATCH] Generate lockfile automatically on new tag --- .forgejo/patches/ghc-9.8.patch | 18 ++++++ ...rate-tarball.yml => generate-lockfile.yml} | 40 ++++++------ .forgejo/workflows/mirror-repository.yml | 62 +++++++++++-------- 3 files changed, 76 insertions(+), 44 deletions(-) create mode 100644 .forgejo/patches/ghc-9.8.patch rename .forgejo/workflows/{generate-tarball.yml => generate-lockfile.yml} (69%) diff --git a/.forgejo/patches/ghc-9.8.patch b/.forgejo/patches/ghc-9.8.patch new file mode 100644 index 0000000000..85796d787d --- /dev/null +++ b/.forgejo/patches/ghc-9.8.patch @@ -0,0 +1,18 @@ +Support ghc-9.8 by widening a lot of constraints. + +This patch can be removed once upstream supports ghc 9.8 offically. + +diff -uprN git-annex-10.20240227.orig/cabal.project git-annex-10.20240227/cabal.project +--- git-annex-10.20240227.orig/cabal.project 1970-01-01 01:00:00.000000000 +0100 ++++ git-annex-10.20240227/cabal.project 2024-04-28 13:30:14.061706299 +0200 +@@ -0,0 +1,10 @@ ++packages: *.cabal ++ ++allow-newer: dav ++allow-newer: haskeline:filepath ++allow-newer: haskeline:directory ++allow-newer: xml-hamlet ++allow-newer: aws:filepath ++allow-newer: dbus:network ++allow-newer: dbus:filepath ++allow-newer: microstache:filepath diff --git a/.forgejo/workflows/generate-tarball.yml b/.forgejo/workflows/generate-lockfile.yml similarity index 69% rename from .forgejo/workflows/generate-tarball.yml rename to .forgejo/workflows/generate-lockfile.yml index afc91a2380..0d98abd451 100644 --- a/.forgejo/workflows/generate-tarball.yml +++ b/.forgejo/workflows/generate-lockfile.yml @@ -6,6 +6,10 @@ on: required: true type: string + push: + tags: + - '*' + jobs: cabal-config-edge: name: Generate cabal config for edge @@ -13,58 +17,52 @@ jobs: container: image: alpine:edge env: - CI_PROJECT_NAME: git-annex CI_ALPINE_TARGET_RELEASE: edge steps: - name: Environment setup - run: apk add nodejs git cabal patch wget + run: apk add nodejs git cabal patch - name: Repo pull uses: actions/checkout@v4 with: - fetch-depth: 500 + fetch-depth: 1 ref: ${{ inputs.ref_name }} - name: Config generation run: | - wget 'https://lab.ilot.io/mirrors/git-annex/-/raw/gitlab-ci/ghc-9.8.patch' - patch -p1 -i ghc-9.8.patch + patch -p1 -i .forgejo/patches/ghc-9.8.patch HOME="${{ github.workspace}}"/cabal_cache cabal update HOME="${{ github.workspace}}"/cabal_cache cabal v2-freeze --shadow-installed-packages --strong-flags --flags="+assistant +webapp +pairing +production +torrentparser +magicmime +benchmark -debuglocks +dbus +networkbsd +gitlfs +httpclientrestricted" - find . - mv cabal.project.freeze git-annex-${{ input.ref_name }}-$CI_ALPINE_TARGET_RELEASE.config + mv cabal.project.freeze git-annex.config - name: Package upload uses: forgejo/upload-artifact@v3 with: name: cabalconfigedge - path: git-annex* + path: git-annex*.config cabal-config-v320: name: Generate cabal config for edge runs-on: x86_64 container: image: alpine:3.20 env: - CI_PROJECT_NAME: git-annex CI_ALPINE_TARGET_RELEASE: v3.20 steps: - name: Environment setup - run: apk add nodejs git cabal patch wget + run: apk add nodejs git cabal patch - name: Repo pull uses: actions/checkout@v4 with: - fetch-depth: 500 + fetch-depth: 1 ref: ${{ inputs.ref_name }} - name: Config generation run: | - wget 'https://lab.ilot.io/mirrors/git-annex/-/raw/gitlab-ci/ghc-9.8.patch' - patch -p1 -i ghc-9.8.patch + patch -p1 -i .forgejo/patches/ghc-9.8.patch HOME="${{ github.workspace }}"/cabal_cache cabal update HOME="${{ github.workspace }}"/cabal_cache cabal v2-freeze --shadow-installed-packages --strong-flags --flags="+assistant +webapp +pairing +production +torrentparser +magicmime +benchmark -debuglocks +dbus +networkbsd +gitlfs +httpclientrestricted" - mv cabal.project.freeze git-annex-${{ input.ref_name }}-$CI_ALPINE_TARGET_RELEASE.config - find . + mv cabal.project.freeze git-annex.config - name: Package upload uses: forgejo/upload-artifact@v3 with: name: cabalconfig320 - path: git-annex* + path: git-annex*.config upload-tarball: name: Upload to generic repo runs-on: x86_64 @@ -78,6 +76,10 @@ jobs: uses: forgejo/download-artifact@v3 - name: Package deployment run: | - find . - curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./cabalconfigedge/git-annex.cabal ${{ github.server_url }}/api/packages/mirrors/generic/git-annex/${{ inputs.ref_name }}/git-annex-${{ inputs.ref_name }}-edge.cabal - curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./cabalconfig320/git-annex.cabal ${{ github.server_url }}/api/packages/mirrors/generic/git-annex/${{ inputs.ref_name }}/git-annex-${{ inputs.ref_name }}-v320.cabal + if test $GITHUB_REF_NAME == "ci" ; then + CI_REF_NAME=${{ inputs.ref_name }} + else + CI_REF_NAME=$GITHUB_REF_NAME + fi + curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./cabalconfigedge/git-annex.config ${{ github.server_url }}/api/packages/mirrors/generic/git-annex/$CI_REF_NAME/git-annex-$CI_REF_NAME-edge.cabal + curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./cabalconfig320/git-annex.config ${{ github.server_url }}/api/packages/mirrors/generic/git-annex/$CI_REF_NAME/git-annex-$CI_REF_NAME-v320.cabal diff --git a/.forgejo/workflows/mirror-repository.yml b/.forgejo/workflows/mirror-repository.yml index 791fe23d0e..b820421db5 100644 --- a/.forgejo/workflows/mirror-repository.yml +++ b/.forgejo/workflows/mirror-repository.yml @@ -4,35 +4,47 @@ on: schedule: - cron: '@hourly' - push: - branches: - - 'master' - jobs: mirror: name: Pull from upstream runs-on: x86_64 container: - image: 'docker.io/node:20-bookworm' + image: alpine:latest + env: + upstream: https://git.joeyh.name/git/git-annex.git + tags: '10.2024*' steps: - - name: git mirror branches {v*/,}master & tags + - name: Environment setup + run: apk add grep git sed coreutils bash nodejs + - name: Fetch destination + uses: actions/checkout@v4 + with: + fetch_depth: 1 + ref: ci + token: ${{ secrets.CODE_FORGEJO_TOKEN }} + - name: Missing tag detecting run: | - git init --bare . - git remote add origin https://git.joeyh.name/git/git-annex.git - git fetch origin refs/heads/master:refs/mirror/master - git ls-remote origin refs/heads/v*/master | while read sha full_ref ; do - ref=${full_ref#refs/heads/} - git fetch origin $full_ref:refs/mirror/$ref - tag=${ref%/master} - git fetch origin refs/tags/${tag}*:refs/mirror-tags/${tag}* - done - if test "${{ vars.TEST }}" != true ; then - token=${{ secrets.CODE_FORGEJO_TOKEN }} - destination=${{ vars.DESTINATION }} - owner=${{ vars.OWNER }} - else - token=${{ secrets.TEST_FORGEJO_TOKEN }} - destination=${{ vars.TEST_DESTINATION }} - owner=${{ vars.TEST_OWNER }} - fi - git push --force https://any:$token@$destination/$owner/git-annex refs/mirror/*:refs/heads/* refs/mirror-tags/*:refs/tags/* --tags + git ls-remote $upstream "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > upstream_tags + git ls-remote ${{ github.server_url}}/${{ github.repository }} "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > destination_tags + cat upstream_tags destination_tags | tr ' ' '\n' | sort | uniq -u > missing_tags + echo "Missing tags:" + cat missing_tags + - name: Missing tag fetch + run: | + git remote add upstream $upstream + while read tag; do + git fetch upstream tag $tag --no-tags + done < missing_tags + - name: Packaging workflow injection + run: | + while read tag; do + git checkout $tag + git tag -d $tag + git checkout ci -- ./.forgejo + git config user.name "forgejo-actions[bot]" + git config user.email "dev@ayakael.net" + git commit -m 'Inject custom workflow' + git tag -a $tag -m $tag + done < missing_tags + - name: Push to destination + run: git push --force origin refs/tags/*:refs/tags/* --tags