From 08f545c3661f36af1f4d493408ee6b00ac4bb223 Mon Sep 17 00:00:00 2001 From: crystal Date: Sat, 27 Apr 2024 18:55:53 -0600 Subject: [PATCH] [squash] Switch to Forgejo Actions --- .ci-make.sh | 64 ++++- .crystalintegration.yml | 360 ----------------------------- .forgejo/workflows/forgejo-deb.yml | 215 +++++++++++++++++ .gitmodules | 2 +- README.md | 2 - repo-deb/build.sh | 7 +- 6 files changed, 284 insertions(+), 366 deletions(-) delete mode 100644 .crystalintegration.yml create mode 100644 .forgejo/workflows/forgejo-deb.yml diff --git a/.ci-make.sh b/.ci-make.sh index 7141acf..431cb4f 100755 --- a/.ci-make.sh +++ b/.ci-make.sh @@ -19,6 +19,40 @@ case "$1" in make "$@" exit $? ;; + "actions-prep") + case "$2" in + "build-forgejo-deb") + APREP_APT_EXTRAS="debhelper devscripts sudo" + ;; + "installtest") + APREP_APT_EXTRAS="sudo" + ;; + "") + APREP_APT_EXTRAS= + ;; + *) + echo "Invalid argument: $2" + exit 98 + ;; + esac + EXIT_TOTAL=0 + apt update + EXIT_TOTAL=$(($EXIT_TOTAL+$?)) + apt upgrade -y + EXIT_TOTAL=$(($EXIT_TOTAL+$?)) + if [ "$APREP_APT_EXTRAS" ] ; then + apt install $APREP_APT_EXTRAS -y + EXIT_TOTAL=$(($EXIT_TOTAL+$?)) + fi + ACTIONS_FORGEJOSHA="$(git rev-parse --short=10 HEAD)" + if [ "$GITHUB_REF_TYPE" = "tag" ] ; then + echo "::set-output name=artifactlabel::$GITHUB_REF_NAME-$ACTIONS_FORGEJOSHA" + else + echo "::set-output name=artifactlabel::$ACTIONS_FORGEJOSHA" + fi + echo "::set-output name=forgejosha::$ACTIONS_FORGEJOSHA" + exit $EXIT_TOTAL + ;; "ci-verify") RETRY_LOOPS=0 while [ $RETRY_LOOPS -le $CI_VERIFY_RETRY_COUNT ] ; do @@ -43,6 +77,26 @@ case "$1" in exit 255 ;; "download-binary") + if [ "$GITHUB_REF_TYPE" = "tag" ] ; then + echo "INFO: Forgejo Actions mode!" + CI_COMMIT_TAG="$GITHUB_REF_NAME" + elif [ "$GITHUB_REF_TYPE" = "branch" ] ; then + echo "WARNING: Not building a tag! Simulating it..." + echo "(forgejo actions mode)" + echo "(this will test the binary packaging without cutting a tag in the package)" + echo "Resolving tag..." + cd forgejo + CI_COMMIT_TAG_RESOLVE=$(git tag --points-at HEAD) + if [ ! $CI_COMMIT_TAG_RESOLVE ] ; then + echo "Failed to resolve exact tag! Getting as close as we can..." + git describe --tags HEAD + CI_COMMIT_TAG_RESOLVE=$(git describe --tags HEAD --abbrev=0) + echo "Closest existing tag: $CI_COMMIT_TAG_RESOLVE" + fi + cd .. + echo "Proceeding with resolved tag: $CI_COMMIT_TAG_RESOLVE" + CI_COMMIT_TAG="$CI_COMMIT_TAG_RESOLVE" + fi if [ $CI_COMMIT_TAG ] ; then CI_RELEASE_ASSETS=$(curl $CI_VERIFY_API/api/v1/repos/$CI_VERIFY_REPO/releases/tags/$CI_COMMIT_TAG | jq -c '.assets[]' | grep linux-amd64) CI_RELEASE_BINARY_URL=$(echo "$CI_RELEASE_ASSETS" | grep linux-amd64\" | jq -r --jsonargs .browser_download_url) @@ -77,9 +131,17 @@ case "$1" in cat deb/.forgejo-bin.control >> deb/debian/control fi ;; + "package-build-deps") + cd deb + mk-build-deps --install --tool "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" --remove + exit $? + ;; "package-build") cd deb - dpkg-buildpackage -b + if [ "$2" = "actions" ] ; then + PACKAGE_BUILD_EXTRA_ARGS="--no-sign" + fi + dpkg-buildpackage -b $PACKAGE_BUILD_EXTRA_ARGS exit $? ;; "package-clean") diff --git a/.crystalintegration.yml b/.crystalintegration.yml deleted file mode 100644 index 7b66393..0000000 --- a/.crystalintegration.yml +++ /dev/null @@ -1,360 +0,0 @@ -labels: - platform: linux/amd64 - -when: - event: [ push, tag ] - -variables: - - &ci_verify_image 'sc.cryxtal.org/ci-img/git-curl-jq:latest' - - &golang_image 'golang:1.22-bullseye' - - &forgejo_test_image 'docker.io/node:20-bookworm' - - &nodejs_image 'docker.io/node:20-bookworm' - - &bin_dl_image 'sc.cryxtal.org/ci-img/bin-dl:latest' - - &deb_build_image 'sc.cryxtal.org/ci-img/dh:bullseye' - - &deb_test_image_bullseye 'sc.cryxtal.org/ci-img/deb-test:bullseye' - - &deb_test_image_bookworm 'sc.cryxtal.org/ci-img/deb-test:bookworm' - - &deb_test_image_buster 'sc.cryxtal.org/ci-img/deb-test:buster' - - &deb_test_image_sid 'sc.cryxtal.org/ci-img/deb-test:sid' - - &deb_test_image_jammy 'sc.cryxtal.org/ci-img/deb-test-ubuntu:jammy' - - &deb_test_image_focal 'sc.cryxtal.org/ci-img/deb-test-ubuntu:focal' - - &deb_test_image_mantic 'sc.cryxtal.org/ci-img/deb-test-ubuntu:mantic' - - &deb_test_image_lunar 'sc.cryxtal.org/ci-img/deb-test-ubuntu:lunar' - - &forgejo_test_golang_ver '1.22' - - &forgejo_test_golang_nodeb_rev '2' - - &build_submodule 'forgejo' - - &goproxy_override '' - - &goproxy_setup |- - if [ -n "$${GOPROXY_OVERRIDE:-}" ]; then - export GOPROXY="$${GOPROXY_OVERRIDE}"; - echo "Using goproxy from goproxy_override \"$${GOPROXY}\""; - elif [ -n "$${GOPROXY_DEFAULT:-}" ]; then - export GOPROXY="$${GOPROXY_DEFAULT}"; - echo "Using goproxy from goproxy_default (secret) not displaying"; - else - export GOPROXY="https://proxy.golang.org,direct"; - echo "No goproxy overrides or defaults given, using \"$${GOPROXY}\""; - fi - -workspace: - base: /go - path: src/cryxtal/forgejo-deb - -clone: - git: - image: woodpeckerci/plugin-git - settings: - recursive: true - -steps: - fetch-tags: - image: *ci_verify_image - pull: true - commands: - - git config --add safe.directory '*' - - git fetch --tags --force - - git submodule foreach 'git fetch --tags --force' - - git-push-codeberg: - image: *ci_verify_image - secrets: [ cb_git_auth ] - commands: - - git remote add codeberg https://$CB_GIT_AUTH@codeberg.org/forgejo-contrib/forgejo-deb - - if ( $(git rev-parse --is-shallow-repository) == "true" );then git fetch --unshallow origin ;fi - - git fetch codeberg - - git push codeberg --tags refs/remotes/origin/*:refs/heads/* - - ci-verify: - image: *ci_verify_image - group: deps - environment: - BUILD_SUBMODULE: *build_submodule - commands: - - ./.ci-make.sh ci-verify "$BUILD_SUBMODULE" - - deps-frontend: - image: *nodejs_image - group: deps - environment: - BUILD_SUBMODULE: *build_submodule - commands: - - ./.ci-make.sh submodule-make "$BUILD_SUBMODULE" deps-frontend - - deps-backend: - image: *golang_image - group: deps - environment: - BUILD_SUBMODULE: *build_submodule - GOPROXY_OVERRIDE: *goproxy_override - commands: - - *goproxy_setup - - ./.ci-make.sh submodule-make "$BUILD_SUBMODULE" deps-backend - - tag-pre-condition: - image: *ci_verify_image - environment: - BUILD_SUBMODULE: *build_submodule - commands: - - cd "$BUILD_SUBMODULE" - - git update-ref refs/heads/tag_test $(git rev-parse --verify HEAD) - - security-check: - image: *golang_image - group: checks - environment: - BUILD_SUBMODULE: *build_submodule - GOPROXY_OVERRIDE: *goproxy_override - commands: - - *goproxy_setup - - ./.ci-make.sh submodule-make "$BUILD_SUBMODULE" security-check - - checks-backend: - image: *forgejo_test_image - group: checks - environment: - GOPROXY_OVERRIDE: *goproxy_override - DEP_GOLANG_VER: *forgejo_test_golang_ver - DEP_GOLANG_NODEB_REV: *forgejo_test_golang_nodeb_rev - commands: - - *goproxy_setup - - ./.ci-make.sh forgejo-test-deps - - su forgejo -c './.ci-make.sh submodule-make forgejo checks-backend' - - chown -R root:root . - - build-frontend: - image: *nodejs_image - group: pre-build - environment: - BUILD_SUBMODULE: *build_submodule - commands: - - ./.ci-make.sh submodule-make "$BUILD_SUBMODULE" frontend - - download-bin-amd64: - image: *bin_dl_image - group: build-main - commands: - - ./.ci-make.sh download-binary forgejo-bin-dl - when: - event: [ tag ] - - build-forgejo-amd64: - image: *golang_image - group: build-main - environment: - BUILD_SUBMODULE: *build_submodule - GOSUMDB: sum.golang.org - TAGS: bindata - GOPROXY_OVERRIDE: *goproxy_override - commands: - - *goproxy_setup - - ./.ci-make.sh submodule-build "$BUILD_SUBMODULE" forgejo-bin - - build-forgejo-sqlite-amd64: - image: *golang_image - environment: - BUILD_SUBMODULE: *build_submodule - GOSUMDB: sum.golang.org - TAGS: bindata sqlite sqlite_unlock_notify - GOPROXY_OVERRIDE: *goproxy_override - commands: - - *goproxy_setup - - ./.ci-make.sh submodule-build "$BUILD_SUBMODULE" forgejo-sqlite-bin - - package-bullseye: - image: *deb_build_image - group: package - commands: - - ./.ci-make.sh package-prep - - ./.ci-make.sh package-build - - ./.ci-make.sh package-clean - - package-repo: - image: *deb_build_image - group: package - commands: - - cd repo-deb - - ./build.sh - - gen-sha256: - image: *ci_verify_image - commands: - - ./.ci-make.sh pkg-gen-sha256 - - ./.ci-make.sh preview-sha256 - - test-inst-bookworm: - image: *deb_test_image_bookworm - group: pkg-test-1 - commands: - - ./.ci-make.sh install-run-test ./forgejo_*_amd64.deb - - test-inst-bookworm-user: - image: *deb_test_image_bookworm - group: pkg-test-1 - commands: - - ./.ci-make.sh test-userinst-prep - - ./.ci-make.sh install-run-test ./forgejo_*_amd64.deb - - test-inst-bullseye-sqlite: - image: *deb_test_image_bullseye - group: pkg-test-1 - commands: - - ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb - - test-inst-bookworm-sqlite: - image: *deb_test_image_bookworm - group: pkg-test-1 - commands: - - ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb - - test-inst-buster-sqlite: - image: *deb_test_image_buster - group: pkg-test-2 - commands: - - ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb - - test-inst-sid-sqlite: - image: *deb_test_image_sid - group: pkg-test-2 - commands: - - ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb - - test-inst-jammy-sqlite: - image: *deb_test_image_jammy - group: pkg-test-2 - commands: - - ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb - - test-inst-focal-sqlite: - image: *deb_test_image_focal - group: pkg-test-2 - commands: - - ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb - - test-inst-mantic-sqlite: - image: *deb_test_image_mantic - group: pkg-test-3 - commands: - - ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb - - test-inst-lunar-sqlite: - image: *deb_test_image_lunar - group: pkg-test-3 - commands: - - ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb - - test-inst-bullseye-bin: - image: *deb_test_image_bullseye - group: pkg-test-3 - commands: - - ./.ci-make.sh install-run-test ./forgejo-bin_*_amd64.deb - when: - event: [ tag ] - - test-inst-bookworm-bin: - image: *deb_test_image_bookworm - group: pkg-test-3 - commands: - - ./.ci-make.sh install-run-test ./forgejo-bin_*_amd64.deb - when: - event: [ tag ] - - test-inst-buster-bin: - image: *deb_test_image_buster - group: pkg-test-4 - commands: - - ./.ci-make.sh install-run-test ./forgejo-bin_*_amd64.deb - when: - event: [ tag ] - - test-inst-sid-bin: - image: *deb_test_image_sid - group: pkg-test-4 - commands: - - ./.ci-make.sh install-run-test ./forgejo-bin_*_amd64.deb - when: - event: [ tag ] - - test-inst-jammy-bin: - image: *deb_test_image_jammy - group: pkg-test-4 - commands: - - ./.ci-make.sh install-run-test ./forgejo-bin_*_amd64.deb - when: - event: [ tag ] - - test-inst-focal-bin: - image: *deb_test_image_focal - group: pkg-test-4 - commands: - - ./.ci-make.sh install-run-test ./forgejo-bin_*_amd64.deb - when: - event: [ tag ] - - test-inst-mantic-bin: - image: *deb_test_image_mantic - group: pkg-test-5 - commands: - - ./.ci-make.sh install-run-test ./forgejo-bin_*_amd64.deb - when: - event: [ tag ] - - test-inst-lunar-bin: - image: *deb_test_image_lunar - group: pkg-test-5 - commands: - - ./.ci-make.sh install-run-test ./forgejo-bin_*_amd64.deb - when: - event: [ tag ] - - test-repo-bookworm-sqlite: - image: *deb_test_image_bookworm - group: pkg-test-5 - commands: - - ./.ci-make.sh install-repo-test ./repo-deb/forgejo-deb-repo_0-0_all.deb forgejo-sqlite - - ./.ci-make.sh force-clean-forgejo - - ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb - - ./.ci-make.sh verify-data-dir-chmod - - upload-crystalcommit: - image: woodpeckerci/plugin-gitea-release - group: upload - settings: - base_url: https://sc.cryxtal.org - files: - - "*.deb" - - "*.deb.sha256" - api_key: - from_secret: sc_api_key - prerelease: false - skip_verify: true - when: - event: [ tag ] - - upload-codeberg: - image: woodpeckerci/plugin-gitea-release - group: upload - settings: - base_url: https://codeberg.org - files: - - "*.deb" - - "*.deb.sha256" - api_key: - from_secret: cb_api_key - prerelease: false - skip_verify: true - when: - event: [ tag ] - - publish-apt-repo: - image: *ci_verify_image - group: upload - environment: - FORGEJO_SITE: https://code.forgejo.org - FORGEJO_OWNER: forgejo-contrib - DEBIAN_DIST: bullseye - DEBIAN_COMPONENT: forgejo-lts - secrets: [ cfo_api_key ] - commands: - - export FORGEJO_KEY=$CFO_API_KEY - - ./.ci-forgejo-apt.sh *.deb - when: - event: [ tag ] diff --git a/.forgejo/workflows/forgejo-deb.yml b/.forgejo/workflows/forgejo-deb.yml new file mode 100644 index 0000000..5b5ba99 --- /dev/null +++ b/.forgejo/workflows/forgejo-deb.yml @@ -0,0 +1,215 @@ +on: [push] +jobs: + build-forgejo-deb: + runs-on: bullseye + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - uses: actions/setup-node@v3 + with: + node-version: 20 + + - uses: actions/setup-go@v4 + with: + go-version: "1.22" + check-latest: true + + - name: "actions prep: build-forgejo-deb" + id: ciprep + run: ./.ci-make.sh actions-prep build-forgejo-deb + + - name: fetch tags + run: | + git config --add safe.directory '*' + git fetch --tags --force + git submodule foreach 'git fetch --tags --force' + + - uses: crystal/install-jq-action@v2.1.0 + - run: ./.ci-make.sh ci-verify forgejo + + - run: ./.ci-make.sh submodule-make forgejo deps-frontend + - run: ./.ci-make.sh submodule-make forgejo deps-backend + + - name: tag pre-condition + run: | + cd forgejo + git update-ref refs/heads/tag_test $(git rev-parse --verify HEAD) + + - run: ./.ci-make.sh submodule-make forgejo security-check + + - run: ./.ci-make.sh submodule-make forgejo frontend + + - run: ./.ci-make.sh submodule-make forgejo checks-backend + + - name: Download Forgejo binary + run: ./.ci-make.sh download-binary forgejo-bin-dl + + - name: Build Forgejo for amd64 + run: ./.ci-make.sh submodule-build forgejo forgejo-bin + env: + TAGS: bindata + + - name: Build Forgejo (with SQLite) for amd64 + run: ./.ci-make.sh submodule-build forgejo forgejo-sqlite-bin + env: + TAGS: bindata sqlite sqlite_unlock_notify + + - run: ./.ci-make.sh package-prep + - run: ./.ci-make.sh package-build-deps + + - run: ./.ci-make.sh package-build actions + + - run: ./.ci-make.sh package-clean + + - name: build repo package + run: | + cd repo-deb + ./build.sh actions + + - name: generate sha256 + run: | + ./.ci-make.sh pkg-gen-sha256 + ./.ci-make.sh preview-sha256 + + - run: ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb + + - uses: actions/upload-artifact@v3 + with: + name: forgejo-deb-${{ steps.ciprep.outputs.artifactlabel }} + path: | + *.deb + *.deb.sha256 + repo-deb/*.deb + + installtest-bookworm-sqlite: + runs-on: bookworm + steps: + - uses: actions/checkout@v4 + + - name: "actions prep: installtest" + id: ciprep + run: ./.ci-make.sh actions-prep installtest + + - uses: actions/download-artifact@v3 + with: + name: forgejo-deb-${{ steps.ciprep.outputs.artifactlabel }} + + - run: ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb + + installtest-bullseye-sqlite: + runs-on: bullseye + steps: + - uses: actions/checkout@v4 + + - name: "actions prep: installtest" + id: ciprep + run: ./.ci-make.sh actions-prep installtest + + - uses: actions/download-artifact@v3 + with: + name: forgejo-deb-${{ steps.ciprep.outputs.artifactlabel }} + + - run: ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb + + installtest-buster-sqlite: + runs-on: buster + steps: + - uses: actions/checkout@v4 + + - name: "actions prep: installtest" + id: ciprep + run: ./.ci-make.sh actions-prep installtest + + - uses: actions/download-artifact@v3 + with: + name: forgejo-deb-${{ steps.ciprep.outputs.artifactlabel }} + + - run: ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb + + installtest-bookworm-user: + runs-on: bookworm + steps: + - uses: actions/checkout@v4 + + - name: "actions prep: installtest" + id: ciprep + run: ./.ci-make.sh actions-prep installtest + + - uses: actions/download-artifact@v3 + with: + name: forgejo-deb-${{ steps.ciprep.outputs.artifactlabel }} + + - run: ./.ci-make.sh test-userinst-prep + - run: ./.ci-make.sh install-run-test ./forgejo_*_amd64.deb + + testsuite-repo-upgrade-sqlite: + runs-on: bookworm + steps: + - uses: actions/checkout@v4 + + - name: "actions prep: installtest" + id: ciprep + run: ./.ci-make.sh actions-prep installtest + + - uses: actions/download-artifact@v3 + with: + name: forgejo-deb-${{ steps.ciprep.outputs.artifactlabel }} + + - run: ./.ci-make.sh install-repo-test ./repo-deb/forgejo-deb-repo_0-0_all.deb forgejo-sqlite + - run: ./.ci-make.sh force-clean-forgejo + - run: ./.ci-make.sh install-run-test ./forgejo-sqlite_*_amd64.deb + - run: ./.ci-make.sh verify-data-dir-chmod + + installtest-buster-bin: + runs-on: buster + steps: + - uses: actions/checkout@v4 + + - name: "actions prep: installtest" + id: ciprep + run: ./.ci-make.sh actions-prep installtest + + - uses: actions/download-artifact@v3 + with: + name: forgejo-deb-${{ steps.ciprep.outputs.artifactlabel }} + + - run: ./.ci-make.sh install-run-test ./forgejo-bin_*_amd64.deb + + publish-release-repo: + runs-on: bookworm + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v4 + + - name: actions prep + id: ciprep + run: ./.ci-make.sh actions-prep + + - uses: actions/download-artifact@v3 + with: + name: forgejo-deb-${{ steps.ciprep.outputs.artifactlabel }} + + - uses: crystal/install-jq-action@v2.1.0 + - run: mkdir forgejo-release + - run: mv *.deb *.deb.sha256 forgejo-release/ + + - uses: actions/forgejo-release@v1 + with: + direction: upload + url: https://codeberg.org + token: ${{ secrets.codeberg_api_key }} + release-dir: forgejo-release + + - name: Debian package registry publish + env: + FORGEJO_SITE: https://code.forgejo.org + FORGEJO_OWNER: forgejo-contrib + DEBIAN_DIST: bullseye + DEBIAN_COMPONENT: forgejo-lts + FORGEJO_KEY: ${{ secrets.cfo_api_key }} + run: | + cd forgejo-release + ../.ci-forgejo-apt.sh *.deb + cd .. diff --git a/.gitmodules b/.gitmodules index 67768c7..5abb796 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "forgejo"] path = forgejo - url = https://sc.cryxtal.org/forgejo/forgejo + url = https://codeberg.org/forgejo/forgejo diff --git a/README.md b/README.md index 1079963..cabed1d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Debian Packages for Forgejo Hello! If you want to run Forgejo on Debian/Ubuntu and you're looking for packages to install it to your system, you've come to the right place! -### Build test: [![ci-status](https://ci.cryxtal.org/api/badges/forgejo-contrib/forgejo-deb/status.svg)](https://ci.cryxtal.org/forgejo-contrib/forgejo-deb) - ## Download info You can find the latest release downloads in [the releases tab](https://codeberg.org/forgejo-contrib/forgejo-deb/releases). There are currently 3 packages built by this script. - `forgejo`: A basic production-ready Forgejo build without SQLite support diff --git a/repo-deb/build.sh b/repo-deb/build.sh index d9eed8c..bdb1ef2 100755 --- a/repo-deb/build.sh +++ b/repo-deb/build.sh @@ -4,10 +4,13 @@ cp code-forgejo-org-forgejo-contrib.asc stub/ cp code-forgejo-org-forgejo-contrib.asc main/ cp forgejo-deb.list stub/ cp forgejo-deb.list main/ +if [ "$1" = "actions" ] ; then + PACKAGE_BUILD_EXTRA_ARGS="--no-sign" +fi cd stub -dpkg-buildpackage -b +dpkg-buildpackage -b $PACKAGE_BUILD_EXTRA_ARGS cd .. cd main -dpkg-buildpackage -b +dpkg-buildpackage -b $PACKAGE_BUILD_EXTRA_ARGS cd .. exit 0