Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85828672
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
50 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/.woodpecker/changelog.yaml b/.woodpecker/changelog.yaml
index 4f38ce618..1d65e8e9f 100644
--- a/.woodpecker/changelog.yaml
+++ b/.woodpecker/changelog.yaml
@@ -1,9 +1,16 @@
when:
- event: pull_request
+variables:
+ script_file_entrypoint: &script_file_entrypoint
+ - /bin/sh
+ - -c
+ - 'printf "%s" "$CI_SCRIPT" | base64 -d > /tmp/ci-script.sh && /bin/sh -xe /tmp/ci-script.sh'
+
steps:
check-changelog:
image: docker.io/alpine:3.23
+ entrypoint: *script_file_entrypoint
commands:
- apk add --no-cache git
- sh ./tools/check-changelog
diff --git a/.woodpecker/docker-combine.yaml b/.woodpecker/docker-combine.yaml
new file mode 100644
index 000000000..c6493df1c
--- /dev/null
+++ b/.woodpecker/docker-combine.yaml
@@ -0,0 +1,57 @@
+when:
+ - event: push
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**", "Dockerfile" ]
+ - event: tag
+ - event: manual
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ - event: manual
+ branch: stable
+
+depends_on:
+ - docker
+
+skip_clone: true
+
+steps:
+ docker-develop-combine:
+ image: git.fluffytail.org/phnt/wpc-docker-tagger:latest
+ when:
+ - event: push
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ - event: manual
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ settings: &docker_settings
+ registry: "git.pleroma.social"
+ image: "pleroma/pleroma"
+ architectures: [amd64, arm64]
+ tags:
+ - latest
+ - develop
+ - ${CI_COMMIT_SHA:0:8}
+ username:
+ from_secret: pleroma-ci-user
+ password:
+ from_secret: pleroma-ci-password
+
+ docker-stable-combine:
+ image: git.fluffytail.org/phnt/wpc-docker-tagger:latest
+ when:
+ - evaluate: 'CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable" && CI_COMMIT_TAG == ""'
+ settings:
+ <<: *docker_settings
+ tags: &stable_docker_tags
+ - latest
+ - stable
+ - ${CI_COMMIT_SHA:0:8}
+
+ docker-stable-tag-combine:
+ image: git.fluffytail.org/phnt/wpc-docker-tagger:latest
+ when:
+ - event: tag
+ - evaluate: 'CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable" && CI_COMMIT_TAG != ""'
+ settings:
+ <<: *docker_settings
+ tags:
+ - <<: *stable_docker_tags
+ - ${CI_COMMIT_TAG}
diff --git a/.woodpecker/docker.yaml b/.woodpecker/docker.yaml
new file mode 100644
index 000000000..abc6bfa3b
--- /dev/null
+++ b/.woodpecker/docker.yaml
@@ -0,0 +1,96 @@
+when:
+ - event: push
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**", "Dockerfile" ]
+ - event: tag
+ - event: manual
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ - event: manual
+ branch: stable
+
+matrix:
+ platform:
+ - linux/amd64
+ - linux/arm64
+
+# This is needed for the when clauses below.
+labels:
+ platform: ${platform}
+ memory: 'high'
+
+variables:
+ docker_variables: &docker_variables
+ repo: pleroma/pleroma
+ registry: git.pleroma.social
+ username:
+ from_secret: pleroma-ci-user
+ password:
+ from_secret: pleroma-ci-password
+ kaniko_image: &kaniko_image woodpeckerci/plugin-kaniko:2.3.1
+
+steps:
+ docker-develop-amd64:
+ image: woodpeckerci/plugin-kaniko:2.3.1
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ settings:
+ <<: *docker_variables
+ tags:
+ - latest-amd64
+ - develop-amd64
+ - ${CI_COMMIT_SHA:0:8}-amd64
+
+ docker-develop-arm64:
+ image: woodpeckerci/plugin-kaniko:2.3.1
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ settings:
+ <<: *docker_variables
+ tags:
+ - latest-arm64
+ - develop-arm64
+ - ${CI_COMMIT_SHA:0:8}-arm64
+
+ docker-stable-amd64:
+ image: *kaniko_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable" && CI_COMMIT_TAG == ""'
+ settings:
+ <<: *docker_variables
+ tags: &amd64_tags
+ - latest-amd64
+ - stable-amd64
+ - ${CI_COMMIT_SHA:0:8}-amd64
+
+ docker-stable-tag-amd64:
+ image: *kaniko_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "tag"'
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable" && CI_COMMIT_TAG != ""'
+ settings:
+ <<: *docker_variables
+ tags:
+ - <<: *amd64_tags
+ - ${CI_COMMIT_TAG}-amd64
+
+ docker-stable-arm64:
+ image: *kaniko_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable" && CI_COMMIT_TAG == ""'
+ settings:
+ <<: *docker_variables
+ tags: &arm64_tags
+ - latest-arm64
+ - stable-arm64
+ - ${CI_COMMIT_SHA:0:8}-arm64
+
+ docker-stable-tag-arm64:
+ image: *kaniko_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "tag"'
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable" && CI_COMMIT_TAG != ""'
+ settings:
+ <<: *docker_variables
+ tags:
+ - <<: *arm64_tags
+ - ${CI_COMMIT_TAG}-arm64
diff --git a/.woodpecker/lint.yaml b/.woodpecker/lint.yaml
index 54de53873..53cfd4e36 100644
--- a/.woodpecker/lint.yaml
+++ b/.woodpecker/lint.yaml
@@ -1,65 +1,74 @@
when:
- event: pull_request
path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**" ]
- event: push
branch: ${CI_REPO_DEFAULT_BRANCH}
path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**" ]
+variables:
+ script_file_entrypoint: &script_file_entrypoint
+ - /bin/sh
+ - -c
+ - 'printf "%s" "$CI_SCRIPT" | base64 -d > /tmp/ci-script.sh && /bin/sh -xe /tmp/ci-script.sh'
+
steps:
mix-format:
image: &elixir-image
docker.io/elixir:1.15-alpine
+ entrypoint: *script_file_entrypoint
failure: ignore
commands:
- |
if ! mix format --check-formatted; then
touch fail.stamp
exit 1
fi
credo:
image: *elixir-image
+ entrypoint: *script_file_entrypoint
failure: ignore
environment:
MIX_ENV: test
commands:
- apk add --no-cache build-base cmake exiftool ffmpeg file-dev git openssl
- adduser -D -h /home/testuser testuser
- mkdir -p /home/testuser/.mix /home/testuser/.hex
- chown -R testuser:testuser . /home/testuser
- su testuser -c "HOME=/home/testuser mix local.hex --force"
- su testuser -c "HOME=/home/testuser mix local.rebar --force"
- su testuser -c "HOME=/home/testuser mix deps.get"
- |
if ! su testuser -c "HOME=/home/testuser mix analyze"; then
touch fail.stamp
exit 1
fi
# cycles:
# image: *elixir-image
# failure: ignore
# commands:
# - apk add --no-cache build-base cmake exiftool ffmpeg file-dev git openssl
# - adduser -D -h /home/testuser testuser
# - mkdir -p /home/testuser/.mix /home/testuser/.hex
# - chown -R testuser:testuser . /home/testuser
# - su testuser -c "HOME=/home/testuser mix local.hex --force"
# - su testuser -c "HOME=/home/testuser mix local.rebar --force"
# - su testuser -c "HOME=/home/testuser mix compile"
# - |
# if ! su testuser -c "HOME=/home/testuser mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != \"No cycles found\")}'"; then
# touch fail.stamp
# exit 1
# fi
ensure-status:
image: *elixir-image
+ entrypoint: *script_file_entrypoint
commands: |
if test -f fail.stamp; then
echo "One or more previous steps fails. Failing workflow..."
exit 1
else
echo "All steps passed"
exit 0
fi
diff --git a/.woodpecker/otp-musl.yaml b/.woodpecker/otp-musl.yaml
new file mode 100644
index 000000000..6f007a127
--- /dev/null
+++ b/.woodpecker/otp-musl.yaml
@@ -0,0 +1,286 @@
+when:
+ - event: push
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**" ]
+ - event: tag
+ - event: manual
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ - event: manual
+ branch: stable
+
+matrix:
+ platform:
+ - linux/amd64
+ - linux/arm
+ - linux/arm64
+
+# This is needed for the when clauses below.
+# When the platform clause is fixed, this might not be needed anymore
+labels:
+ platform: ${platform}
+
+variables:
+ script_file_entrypoint: &script_file_entrypoint
+ - /bin/sh
+ - -c
+ - 'printf "%s" "$CI_SCRIPT" | base64 -d > /tmp/ci-script.sh && /bin/sh -xe /tmp/ci-script.sh'
+ build_cmds: &build_cmds
+ - apk add git build-base cmake file-dev openssl vips-dev zip
+ - echo "import Config" > config/prod.secret.exs
+ - mix local.hex --force
+ - mix local.rebar --force
+ - mix deps.get --only prod
+ - mkdir release
+ - export PLEROMA_BUILD_BRANCH=${CI_COMMIT_BRANCH}
+ - mix release --path release
+ build_image_amd64: &build_image_amd64 docker.io/hexpm/elixir-amd64:1.17.3-erlang-27.3.4.2-alpine-3.22.1
+ build_image_arm: &build_image_arm docker.io/arm32v7/elixir:1.17.3-alpine
+ build_image_arm64: &build_image_arm64 docker.io/hexpm/elixir-arm64:1.17.3-erlang-27.3.4.2-alpine-3.22.1
+ artifacts_uploader_image: &artifacts_uploader_image docker.io/woodpeckercommunity/plugin-gitea-package:0.5.0
+ artifacts_uploader_settings: &artifacts_uploader_settings
+ user:
+ from_secret: pleroma-ci-user
+ password:
+ from_secret: pleroma-ci-password
+ owner: 'pleroma'
+ env: &env
+ MIX_ENV: prod
+ VIX_COMPILATION_MODE: PLATFORM_PROVIDED_LIBVIPS
+
+steps:
+ otp-develop-amd64-musl:
+ image: *build_image_amd64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ environment: *env
+ commands: &amd64_build
+ - <<: *build_cmds
+ - zip -9rq ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64-musl.zip release
+
+ otp-stable-amd64-musl:
+ image: *build_image_amd64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable"'
+ environment: *env
+ commands: *amd64_build
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ otp-stable-tag-amd64-musl:
+ image: *build_image_amd64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "tag"'
+ environment: *env
+ commands:
+ - <<: *build_cmds
+ - zip -9rq stable-${CI_COMMIT_SHA:0:8}-amd64-musl.zip release
+
+ otp-develop-arm-musl:
+ image: *build_image_arm
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ environment: *env
+ commands: &arm_build
+ - <<: *build_cmds
+ - zip -9rq ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm-musl.zip release
+
+ otp-stable-arm-musl:
+ image: *build_image_arm
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable"'
+ environment: *env
+ commands: *arm_build
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ otp-stable-tag-arm-musl:
+ image: *build_image_arm
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "tag"'
+ environment: *env
+ commands:
+ - <<: *build_cmds
+ - zip -9rq stable-${CI_COMMIT_SHA:0:8}-arm-musl.zip release
+
+ otp-develop-arm64-musl:
+ image: *build_image_arm64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ environment: *env
+ commands: &arm64_build
+ - <<: *build_cmds
+ - zip -9rq ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64-musl.zip release
+
+ otp-stable-arm64-musl:
+ image: *build_image_arm64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable"'
+ environment: *env
+ commands: *arm64_build
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ otp-stable-tag-arm64-musl:
+ image: *build_image_arm64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "tag"'
+ environment: *env
+ commands:
+ - <<: *build_cmds
+ - zip -9rq stable-${CI_COMMIT_SHA:0:8}-arm64-musl.zip release
+
+ upload-artifacts-amd64-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-amd64-musl
+ package_version: ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64-musl
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64-musl.zip
+ file_name: pleroma-${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64-musl.zip
+
+ upload-latest-amd64-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-amd64-musl
+ package_version: latest
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64-musl.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-artifacts-tag-amd64-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-amd64-musl
+ package_version: stable-${CI_COMMIT_SHA:0:8}-amd64-musl
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-amd64-musl.zip
+ file_name: pleroma-stable-${CI_COMMIT_SHA:0:8}-amd64-musl.zip
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-latest-tag-amd64-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-amd64-musl
+ package_version: latest
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-amd64-musl.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ upload-artifacts-arm-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-arm-musl
+ package_version: ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm-musl
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm-musl.zip
+ file_name: pleroma-${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm-musl.zip
+
+ upload-latest-arm-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-arm-musl
+ package_version: latest
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm-musl.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-artifacts-tag-arm-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-arm-musl
+ package_version: stable-${CI_COMMIT_SHA:0:8}-arm-musl
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-arm-musl.zip
+ file_name: pleroma-stable-${CI_COMMIT_SHA:0:8}-arm-musl.zip
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-latest-tag-arm-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-arm-musl
+ package_version: latest
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-arm-musl.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ upload-artifacts-arm64-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-arm64-musl
+ package_version: ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64-musl
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64-musl.zip
+ file_name: pleroma-${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64-musl.zip
+
+ upload-latest-arm64-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-arm64-musl
+ package_version: latest
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64-musl.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-artifacts-tag-arm64-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-arm64-musl
+ package_version: stable-${CI_COMMIT_SHA:0:8}-arm64-musl
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-arm64-musl.zip
+ file_name: pleroma-stable-${CI_COMMIT_SHA:0:8}-arm64-musl.zip
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-latest-tag-arm64-musl:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-arm64-musl
+ package_version: latest
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-arm64-musl.zip
+ file_name: pleroma.zip
+ update: 'true'
diff --git a/.woodpecker/otp.yaml b/.woodpecker/otp.yaml
new file mode 100644
index 000000000..7e1bad611
--- /dev/null
+++ b/.woodpecker/otp.yaml
@@ -0,0 +1,287 @@
+when:
+ - event: push
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**" ]
+ - event: tag
+ - event: manual
+ branch: ${CI_REPO_DEFAULT_BRANCH}
+ - event: manual
+ branch: stable
+
+matrix:
+ platform:
+ - linux/amd64
+ - linux/arm
+ - linux/arm64
+
+# This is needed for the when clauses below.
+# When the platform clause is fixed, this might not be needed anymore
+labels:
+ platform: ${platform}
+
+variables:
+ script_file_entrypoint: &script_file_entrypoint
+ - /bin/sh
+ - -c
+ - 'printf "%s" "$CI_SCRIPT" | base64 -d > /tmp/ci-script.sh && /bin/sh -xe /tmp/ci-script.sh'
+ build_cmds: &build_cmds
+ - apt-get update && apt-get install -y cmake libmagic-dev libvips-dev erlang-dev git build-essential zip
+ - echo "import Config" > config/prod.secret.exs
+ - mix local.hex --force
+ - mix local.rebar --force
+ - mix deps.get --only prod
+ - mkdir release
+ - export PLEROMA_BUILD_BRANCH=${CI_COMMIT_BRANCH}
+ - mix release --path release
+ build_image_amd64: &build_image_amd64 docker.io/hexpm/elixir-amd64:1.17.3-erlang-27.3.4.2-ubuntu-noble-20250716
+ build_image_arm: &build_image_arm docker.io/arm32v7/elixir:1.17.3
+ build_image_arm64: &build_image_arm64 docker.io/hexpm/elixir-arm64:1.17.3-erlang-27.3.4.2-ubuntu-noble-20250716
+ artifacts_uploader_image: &artifacts_uploader_image docker.io/woodpeckercommunity/plugin-gitea-package:0.5.0
+ artifacts_uploader_settings: &artifacts_uploader_settings
+ user:
+ from_secret: pleroma-ci-user
+ password:
+ from_secret: pleroma-ci-password
+ owner: 'pleroma'
+ env: &env
+ MIX_ENV: prod
+ VIX_COMPILATION_MODE: PLATFORM_PROVIDED_LIBVIPS
+ DEBIAN_FRONTEND: noninteractive
+
+steps:
+ otp-develop-amd64:
+ image: *build_image_amd64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ environment: *env
+ commands: &amd64_build
+ - <<: *build_cmds
+ - zip -9rq ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64.zip release
+
+ otp-stable-amd64:
+ image: *build_image_amd64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable"'
+ environment: *env
+ commands: *amd64_build
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ otp-stable-tag-amd64:
+ image: *build_image_amd64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "tag"'
+ environment: *env
+ commands:
+ - <<: *build_cmds
+ - zip -9rq stable-${CI_COMMIT_SHA:0:8}-amd64.zip release
+
+ otp-develop-arm:
+ image: *build_image_arm
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ environment: *env
+ commands: &arm_build
+ - <<: *build_cmds
+ - zip -9rq ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm.zip release
+
+ otp-stable-arm:
+ image: *build_image_arm
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable"'
+ environment: *env
+ commands: *arm_build
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ otp-stable-tag-arm:
+ image: *build_image_arm
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "tag"'
+ environment: *env
+ commands:
+ - <<: *build_cmds
+ - zip -9rq stable-${CI_COMMIT_SHA:0:8}-arm.zip release
+
+ otp-develop-arm64:
+ image: *build_image_arm64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ environment: *env
+ commands: &arm64_build
+ - <<: *build_cmds
+ - zip -9rq ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64.zip release
+
+ otp-stable-arm64:
+ image: *build_image_arm64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "manual" && CI_COMMIT_BRANCH == "stable"'
+ environment: *env
+ commands: *arm64_build
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ otp-stable-tag-arm64:
+ image: *build_image_arm64
+ entrypoint: *script_file_entrypoint
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "tag"'
+ environment: *env
+ commands:
+ - <<: *build_cmds
+ - zip -9rq stable-${CI_COMMIT_SHA:0:8}-arm64.zip release
+
+ upload-artifacts-amd64:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-amd64
+ package_version: ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64.zip
+ file_name: pleroma-${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64.zip
+
+ upload-latest-amd64:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-amd64
+ package_version: latest
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-amd64.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-artifacts-tag-amd64:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-amd64
+ package_version: stable-${CI_COMMIT_SHA:0:8}-amd64
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-amd64.zip
+ file_name: pleroma-stable-${CI_COMMIT_SHA:0:8}-amd64.zip
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-latest-tag-amd64:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/amd64" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-amd64
+ package_version: latest
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-amd64.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ upload-artifacts-arm:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-arm
+ package_version: ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm.zip
+ file_name: pleroma-${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm.zip
+
+ upload-latest-arm:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-arm
+ package_version: latest
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-artifacts-tag-arm:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-arm
+ package_version: stable-${CI_COMMIT_SHA:0:8}-arm
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-arm.zip
+ file_name: pleroma-stable-${CI_COMMIT_SHA:0:8}-arm.zip
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-latest-tag-arm:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-arm
+ package_version: latest
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-arm.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ upload-artifacts-arm64:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-arm64
+ package_version: ${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64.zip
+ file_name: pleroma-${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64.zip
+
+ upload-latest-arm64:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "push" && CI_COMMIT_BRANCH == "${CI_REPO_DEFAULT_BRANCH}"'
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "manual"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-${CI_COMMIT_BRANCH}-arm64
+ package_version: latest
+ file_source: ./${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:8}-arm64.zip
+ file_name: pleroma.zip
+ update: 'true'
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-artifacts-tag-arm64:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-arm64
+ package_version: stable-${CI_COMMIT_SHA:0:8}-arm64
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-arm64.zip
+ file_name: pleroma-stable-${CI_COMMIT_SHA:0:8}-arm64.zip
+
+ # Tag events don't have CI_COMMIT_BRANCH set, hardcode stable
+ upload-latest-tag-arm64:
+ image: *artifacts_uploader_image
+ when:
+ - evaluate: 'platform == "linux/arm64" && CI_PIPELINE_EVENT == "tag"'
+ settings:
+ <<: *artifacts_uploader_settings
+ package_name: pleroma-otp-stable-arm64
+ package_version: latest
+ file_source: ./stable-${CI_COMMIT_SHA:0:8}-arm64.zip
+ file_name: pleroma.zip
+ update: 'true'
diff --git a/.woodpecker/unit-testing-elixir-1.15.yaml b/.woodpecker/unit-testing-elixir-1.15.yaml
index 43f30262a..6ac333e76 100644
--- a/.woodpecker/unit-testing-elixir-1.15.yaml
+++ b/.woodpecker/unit-testing-elixir-1.15.yaml
@@ -1,34 +1,41 @@
when:
- event: pull_request
path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**" ]
- event: push
branch: ${CI_REPO_DEFAULT_BRANCH}
path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**" ]
depends_on:
- lint
+variables:
+ script_file_entrypoint: &script_file_entrypoint
+ - /bin/sh
+ - -c
+ - 'printf "%s" "$CI_SCRIPT" | base64 -d > /tmp/ci-script.sh && /bin/sh -xe /tmp/ci-script.sh'
+
steps:
unit-testing-elixir-1.15:
image: elixir:1.15-alpine
+ entrypoint: *script_file_entrypoint
environment:
MIX_ENV: test
DB_HOST: postgres
DB_PORT: 5432
commands:
- apk add --no-cache build-base cmake exiftool ffmpeg file-dev git openssl
- adduser -D -h /home/testuser testuser
- mkdir -p /home/testuser/.mix /home/testuser/.hex
- chown -R testuser:testuser . /home/testuser
- su testuser -c "HOME=/home/testuser mix local.hex --force"
- su testuser -c "HOME=/home/testuser mix local.rebar --force"
- su testuser -c "HOME=/home/testuser mix deps.get"
- su testuser -c "HOME=/home/testuser mix pleroma.test_runner --preload-modules"
services:
postgres:
image: postgres:13-alpine
environment:
POSTGRES_DB: pleroma_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
diff --git a/.woodpecker/unit-testing-elixir-1.18.yaml b/.woodpecker/unit-testing-elixir-1.18.yaml
index 1963b36a5..3468f2688 100644
--- a/.woodpecker/unit-testing-elixir-1.18.yaml
+++ b/.woodpecker/unit-testing-elixir-1.18.yaml
@@ -1,34 +1,41 @@
when:
- event: pull_request
path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**" ]
- event: push
branch: ${CI_REPO_DEFAULT_BRANCH}
path: [ "**/*.ex", "**/*.eex", "**/*.exs", "mix.lock", ".woodpecker/**" ]
depends_on:
- lint
+variables:
+ script_file_entrypoint: &script_file_entrypoint
+ - /bin/sh
+ - -c
+ - 'printf "%s" "$CI_SCRIPT" | base64 -d > /tmp/ci-script.sh && /bin/sh -xe /tmp/ci-script.sh'
+
steps:
unit-testing-elixir-1.18:
image: elixir:1.18-otp-27-alpine
+ entrypoint: *script_file_entrypoint
environment:
MIX_ENV: test
DB_HOST: postgres
DB_PORT: 5432
commands:
- apk add --no-cache build-base cmake exiftool ffmpeg file-dev git openssl
- adduser -D -h /home/testuser testuser
- mkdir -p /home/testuser/.mix /home/testuser/.hex
- chown -R testuser:testuser . /home/testuser
- su testuser -c "HOME=/home/testuser mix local.hex --force"
- su testuser -c "HOME=/home/testuser mix local.rebar --force"
- su testuser -c "HOME=/home/testuser mix deps.get"
- su testuser -c "HOME=/home/testuser mix pleroma.test_runner --preload-modules"
services:
postgres:
image: postgres:13-alpine
environment:
POSTGRES_DB: pleroma_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
diff --git a/changelog.d/woodpecker-release-pipeline.skip b/changelog.d/woodpecker-release-pipeline.skip
new file mode 100644
index 000000000..e69de29bb
diff --git a/lib/pleroma/release_tasks.ex b/lib/pleroma/release_tasks.ex
index af2d35c8f..49400940f 100644
--- a/lib/pleroma/release_tasks.ex
+++ b/lib/pleroma/release_tasks.ex
@@ -1,67 +1,84 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ReleaseTasks do
@repo Pleroma.Repo
- def run(args) do
+ # TODO: Kept for some backwards compatibility with buggy pleroma_ctl,
+ # if a mismatch between pleroma_ctl and Pleroma accidentaly happens.
+ # Remove in the future.
+ def run(args) when is_binary(args) do
[task | args] = String.split(args)
case task do
"migrate" -> migrate(args)
"create" -> create()
"rollback" -> rollback(args)
task -> mix_task(task, args)
end
end
+ # HACK: Script arguments need to be received as a list, otherwise (quoted) arguments with
+ # whitespace will be broken. Previously the broken string form above was used,
+ # escaping in the shell does not help.
+ def run(args) when is_list(args) do
+ [task | args] = args
+
+ case task do
+ "migrate" -> migrate(args)
+ "create" -> create()
+ "rollback" -> rollback(args)
+ task -> mix_task(task, args)
+ end
+ end
+
def find_module(task) do
module_name =
task
|> String.split(".")
|> Enum.map(&String.capitalize/1)
|> then(fn x -> [Mix, Tasks, Pleroma] ++ x end)
|> Module.concat()
case Code.ensure_loaded(module_name) do
{:module, _} -> module_name
_ -> nil
end
end
defp mix_task(task, args) do
Application.load(:pleroma)
module = find_module(task)
if module do
module.run(args)
else
IO.puts("The task #{task} does not exist")
end
end
def migrate(args) do
Mix.Tasks.Pleroma.Ecto.Migrate.run(args)
end
def rollback(args) do
Mix.Tasks.Pleroma.Ecto.Rollback.run(args)
end
def create do
Application.load(:pleroma)
case @repo.__adapter__.storage_up(@repo.config) do
:ok ->
IO.puts("The database for #{inspect(@repo)} has been created")
{:error, :already_up} ->
IO.puts("The database for #{inspect(@repo)} has already been created")
{:error, term} when is_binary(term) ->
IO.puts(:stderr, "The database for #{inspect(@repo)} couldn't be created: #{term}")
end
end
end
diff --git a/rel/files/bin/pleroma_ctl b/rel/files/bin/pleroma_ctl
index 6f0dba3a8..f5d3f321b 100755
--- a/rel/files/bin/pleroma_ctl
+++ b/rel/files/bin/pleroma_ctl
@@ -1,161 +1,173 @@
#!/bin/sh
# XXX: This should be removed when elixir's releases get custom command support
detect_flavour() {
arch="$(uname -m)"
if [ "$arch" = "x86_64" ]; then
arch="amd64"
elif [ "$arch" = "armv7l" ]; then
arch="arm"
elif [ "$arch" = "aarch64" ]; then
arch="arm64"
else
echo "Unsupported arch: $arch" >&2
exit 1
fi
if getconf GNU_LIBC_VERSION >/dev/null; then
libc_postfix=""
elif [ "$(ldd 2>&1 | head -c 9)" = "musl libc" ]; then
libc_postfix="-musl"
elif [ "$(find /lib/libc.musl* | wc -l)" ]; then
libc_postfix="-musl"
else
echo "Unsupported libc" >&2
exit 1
fi
echo "$arch$libc_postfix"
}
detect_branch() {
version="$(cut -d' ' -f2 <"$RELEASE_ROOT"/releases/start_erl.data)"
# Expected format: major.minor.patch_version(-number_of_commits_ahead_of_tag-gcommit_hash).branch
branch="$(echo "$version" | cut -d'.' -f 4)"
if [ "$branch" = "develop" ]; then
echo "develop"
elif [ "$branch" = "" ]; then
echo "stable"
else
# Note: branch name in version is of SemVer format and may only contain [0-9a-zA-Z-] symbols —
# if supporting releases for more branches, need to ensure they contain only these symbols.
echo "Can't detect the branch automatically, please specify it by using the --branch option." >&2
exit 1
fi
}
update() {
set -e
NO_RM=false
while echo "$1" | grep "^-" >/dev/null; do
case "$1" in
--zip-url)
FULL_URI="$2"
shift 2
;;
--no-rm)
NO_RM=true
shift
;;
--flavour)
FLAVOUR="$2"
shift 2
;;
--branch)
BRANCH="$2"
shift 2
;;
--tmp-dir)
TMP_DIR="$2"
shift 2
;;
-*)
echo "invalid option: $1" 1>&2
shift
;;
esac
done
RELEASE_ROOT=$(dirname "$SCRIPTPATH")
uri="https://git.pleroma.social"
- project_id="2"
- project_branch="${BRANCH:-$(detect_branch)}"
- flavour="${FLAVOUR:-$(detect_flavour)}"
+ project_name="pleroma"
+ package_base="${uri}/api/packages/${project_name}/generic"
+ if [ -n "$FULL_URI" ]; then
+ full_uri="$FULL_URI"
+ else
+ project_branch="${BRANCH:-$(detect_branch)}"
+ flavour="${FLAVOUR:-$(detect_flavour)}"
+ full_uri="${package_base}"/pleroma-otp-"${project_branch}"-"${flavour}"/latest/pleroma.zip
+ fi
tmp="${TMP_DIR:-/tmp}"
artifact="$tmp/pleroma.zip"
- full_uri="${FULL_URI:-${uri}/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=${flavour}}"
echo "Downloading the artifact from ${full_uri} to ${artifact}"
- curl "$full_uri" -o "${artifact}"
+ curl -fL "$full_uri" -o "${artifact}"
echo "Unpacking ${artifact} to ${tmp}"
unzip -q "$artifact" -d "$tmp"
echo "Copying files over to $RELEASE_ROOT"
if [ "$NO_RM" = false ]; then
echo "Removing files from the previous release"
rm -r "${RELEASE_ROOT:-?}"/*
fi
cp -rf "$tmp/release"/* "$RELEASE_ROOT"
echo "Removing temporary files"
rm -r "$tmp/release"
rm "$artifact"
echo "Done! Please refer to the changelog/release notes for changes and update instructions"
set +e
}
if [ -z "$1" ] || [ "$1" = "help" ]; then
# TODO: Just list the commands on `pleroma_ctl help` and output help for the individual command on `pleroma_ctl help $COMMAND`
echo "Usage: $(basename "$0") COMMAND [ARGS]
The known commands are:
create
Create database schema (needs to be executed only once)
migrate
Execute database migrations (needs to be done after updates)
rollback [VERSION]
Rollback database migrations (needs to be done before downgrading)
update [OPTIONS]
Update the instance.
Options:
--branch Update to a specified branch, instead of the latest version of the current one.
--flavour Update to a specified flavour (CPU architecture+libc), instead of the current one.
--zip-url Get the release from a specified url. If set, renders the previous 2 options inactive.
--no-rm Do not erase previous release's files.
--tmp-dir Download the temporary files to a specified directory.
and any mix tasks under Pleroma namespace, for example \`mix pleroma.user COMMAND\` is
equivalent to \`$(basename "$0") user COMMAND\`
By default pleroma_ctl will try calling into a running instance to execute non migration-related commands,
if for some reason this is undesired, set PLEROMA_CTL_RPC_DISABLED environment variable.
"
else
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
- FULL_ARGS="$*"
+ # HACK: Script arguments need to be sent as an array to Mix tasks, otherwise they will break (quoted) arguments with whitespace.
+ # Previously it was sent as string, which would get split on whitespace on the task side.
+ # Encode as Elixir binary literals to avoid string escaping and interpolation issues.
+ PREPARED_ARGS=""
+ for arg in "$@"; do
+ bytes=$(printf '%s' "$arg" | od -An -v -tu1 | tr -s '[:space:]' ',' | sed 's/^,//; s/,$//')
+ PREPARED_ARGS="$PREPARED_ARGS <<$bytes>>,"
+ done
ACTION="$1"
if [ $# -gt 0 ]; then
shift
fi
echo "$1" | grep "^-" >/dev/null
if [ $? -eq 1 ]; then
SUBACTION="$1"
if [ $# -gt 0 ]; then
shift
fi
fi
if [ "$ACTION" = "update" ]; then
update "$@"
elif [ "$ACTION" = "migrate" ] || [ "$ACTION" = "rollback" ] || [ "$ACTION" = "create" ] || [ "$ACTION $SUBACTION" = "instance gen" ] || [ "$PLEROMA_CTL_RPC_DISABLED" = true ]; then
- "$SCRIPTPATH"/pleroma eval 'Pleroma.ReleaseTasks.run("'"$FULL_ARGS"'")'
+ "$SCRIPTPATH"/pleroma eval 'Pleroma.ReleaseTasks.run(['"${PREPARED_ARGS%%,}"'])'
else
- "$SCRIPTPATH"/pleroma rpc 'Pleroma.ReleaseTasks.run("'"$FULL_ARGS"'")'
+ "$SCRIPTPATH"/pleroma rpc 'Pleroma.ReleaseTasks.run(['"${PREPARED_ARGS%%,}"'])'
fi
fi
diff --git a/test/pleroma/pleroma_ctl_test.exs b/test/pleroma/pleroma_ctl_test.exs
new file mode 100644
index 000000000..d96396399
--- /dev/null
+++ b/test/pleroma/pleroma_ctl_test.exs
@@ -0,0 +1,293 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.PleromaCtlTest do
+ use ExUnit.Case, async: false
+
+ @pleroma_ctl Path.expand("../../rel/files/bin/pleroma_ctl", __DIR__)
+
+ setup do
+ tmp_dir =
+ Path.join(System.tmp_dir!(), "pleroma_ctl_test_#{System.unique_integer([:positive])}")
+
+ release_root = Path.join(tmp_dir, "release")
+ bin_dir = Path.join(release_root, "bin")
+
+ File.mkdir_p!(bin_dir)
+ File.cp!(@pleroma_ctl, Path.join(bin_dir, "pleroma_ctl"))
+ File.chmod!(Path.join(bin_dir, "pleroma_ctl"), 0o755)
+
+ on_exit(fn -> File.rm_rf!(tmp_dir) end)
+
+ {:ok, tmp_dir: tmp_dir, release_root: release_root, bin_dir: bin_dir}
+ end
+
+ test "update downloads branch-scoped latest OTP package", %{
+ tmp_dir: tmp_dir,
+ bin_dir: bin_dir,
+ release_root: release_root
+ } do
+ stubs_dir = Path.join(tmp_dir, "stubs")
+ curl_args_path = Path.join(tmp_dir, "curl.args")
+ File.mkdir_p!(stubs_dir)
+ write_update_stubs(stubs_dir, curl_args_path, "unused", "glibc")
+
+ update_tmp_dir = Path.join(tmp_dir, "update_tmp")
+ File.mkdir_p!(update_tmp_dir)
+
+ {output, status} =
+ System.cmd(
+ Path.join(bin_dir, "pleroma_ctl"),
+ [
+ "update",
+ "--branch",
+ "develop",
+ "--flavour",
+ "amd64",
+ "--tmp-dir",
+ update_tmp_dir,
+ "--no-rm"
+ ],
+ env: [{"PATH", stubs_dir <> ":" <> System.get_env("PATH", "")}],
+ stderr_to_stdout: true
+ )
+
+ assert status == 0, output
+ assert File.exists?(Path.join(release_root, "bin/marker"))
+
+ assert ["-fL", url, "-o", artifact_path] =
+ curl_args_path
+ |> File.read!()
+ |> String.split("\n", trim: true)
+
+ assert url ==
+ "https://git.pleroma.social/api/packages/pleroma/generic/pleroma-otp-develop-amd64/latest/pleroma.zip"
+
+ assert artifact_path == Path.join(update_tmp_dir, "pleroma.zip")
+ end
+
+ test "update detects stable branch and local flavour", %{
+ tmp_dir: tmp_dir,
+ bin_dir: bin_dir,
+ release_root: release_root
+ } do
+ stubs_dir = Path.join(tmp_dir, "stubs")
+ curl_args_path = Path.join(tmp_dir, "curl.args")
+ File.mkdir_p!(stubs_dir)
+ write_update_stubs(stubs_dir, curl_args_path, "x86_64", "glibc")
+ write_start_erl_data(release_root, "2.10.0")
+
+ {output, status} =
+ System.cmd(
+ Path.join(bin_dir, "pleroma_ctl"),
+ ["update", "--tmp-dir", create_update_tmp_dir(tmp_dir), "--no-rm"],
+ env: [{"PATH", stubs_dir <> ":" <> System.get_env("PATH", "")}],
+ stderr_to_stdout: true
+ )
+
+ assert status == 0, output
+
+ assert curl_url(curl_args_path) ==
+ "https://git.pleroma.social/api/packages/pleroma/generic/pleroma-otp-stable-amd64/latest/pleroma.zip"
+ end
+
+ test "update detects develop branch and musl arm flavour", %{
+ tmp_dir: tmp_dir,
+ bin_dir: bin_dir,
+ release_root: release_root
+ } do
+ stubs_dir = Path.join(tmp_dir, "stubs")
+ curl_args_path = Path.join(tmp_dir, "curl.args")
+ File.mkdir_p!(stubs_dir)
+ write_update_stubs(stubs_dir, curl_args_path, "armv7l", "musl")
+ write_start_erl_data(release_root, "2.10.0.develop")
+
+ {output, status} =
+ System.cmd(
+ Path.join(bin_dir, "pleroma_ctl"),
+ ["update", "--tmp-dir", create_update_tmp_dir(tmp_dir), "--no-rm"],
+ env: [{"PATH", stubs_dir <> ":" <> System.get_env("PATH", "")}],
+ stderr_to_stdout: true
+ )
+
+ assert status == 0, output
+
+ assert curl_url(curl_args_path) ==
+ "https://git.pleroma.social/api/packages/pleroma/generic/pleroma-otp-develop-arm-musl/latest/pleroma.zip"
+ end
+
+ test "update with zip URL bypasses branch and flavour detection", %{
+ tmp_dir: tmp_dir,
+ bin_dir: bin_dir,
+ release_root: release_root
+ } do
+ stubs_dir = Path.join(tmp_dir, "stubs")
+ curl_args_path = Path.join(tmp_dir, "curl.args")
+ File.mkdir_p!(stubs_dir)
+ write_update_stubs(stubs_dir, curl_args_path, "unsupported-arch", "unsupported-libc")
+ write_start_erl_data(release_root, "2.10.0.custombranch")
+
+ custom_url = "https://example.test/custom.zip"
+
+ {output, status} =
+ System.cmd(
+ Path.join(bin_dir, "pleroma_ctl"),
+ [
+ "update",
+ "--zip-url",
+ custom_url,
+ "--tmp-dir",
+ create_update_tmp_dir(tmp_dir),
+ "--no-rm"
+ ],
+ env: [{"PATH", stubs_dir <> ":" <> System.get_env("PATH", "")}],
+ stderr_to_stdout: true
+ )
+
+ assert status == 0, output
+ assert curl_url(curl_args_path) == custom_url
+ end
+
+ test "passes arguments with spaces and Elixir string metacharacters", %{
+ tmp_dir: tmp_dir,
+ bin_dir: bin_dir
+ } do
+ capture_path = Path.join(tmp_dir, "captured_args")
+ eval_path = Path.join(tmp_dir, "pleroma_ctl_eval.exs")
+
+ write_executable(Path.join(bin_dir, "pleroma"), """
+ #!/bin/sh
+ {
+ printf '%s\n' 'defmodule Pleroma.ReleaseTasks do'
+ printf '%s\n' ' def run(args), do: File.write!(System.fetch_env!("PLEROMA_CTL_CAPTURE"), :erlang.term_to_binary(args))'
+ printf '%s\n' 'end'
+ printf '%s\n' "$2"
+ } > "$PLEROMA_CTL_EVAL_FILE"
+
+ exec elixir "$PLEROMA_CTL_EVAL_FILE"
+ """)
+
+ {output, status} =
+ System.cmd(
+ Path.join(bin_dir, "pleroma_ctl"),
+ [
+ "user",
+ "",
+ "has space",
+ ~s(has "quote"),
+ ~s(has \\ backslash),
+ ~S(#{:not_interpolated})
+ ],
+ env: [
+ {"PLEROMA_CTL_CAPTURE", capture_path},
+ {"PLEROMA_CTL_EVAL_FILE", eval_path}
+ ],
+ stderr_to_stdout: true
+ )
+
+ assert status == 0, output
+
+ assert capture_path
+ |> File.read!()
+ |> :erlang.binary_to_term() == [
+ "user",
+ "",
+ "has space",
+ ~s(has "quote"),
+ ~s(has \\ backslash),
+ ~S(#{:not_interpolated})
+ ]
+ end
+
+ defp write_executable(path, contents) do
+ File.write!(path, contents)
+ File.chmod!(path, 0o755)
+ end
+
+ defp write_start_erl_data(release_root, version) do
+ releases_dir = Path.join(release_root, "releases")
+ File.mkdir_p!(releases_dir)
+ File.write!(Path.join(releases_dir, "start_erl.data"), "erts-15.0 #{version}\n")
+ end
+
+ defp create_update_tmp_dir(tmp_dir) do
+ update_tmp_dir = Path.join(tmp_dir, "update_tmp")
+ File.mkdir_p!(update_tmp_dir)
+ update_tmp_dir
+ end
+
+ defp write_update_stubs(stubs_dir, curl_args_path, arch, libc) do
+ write_executable(Path.join(stubs_dir, "curl"), """
+ #!/bin/sh
+ printf '%s\n' "$@" > "#{curl_args_path}"
+
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ -o)
+ artifact="$2"
+ shift 2
+ ;;
+ *)
+ shift
+ ;;
+ esac
+ done
+
+ : > "$artifact"
+ """)
+
+ write_executable(Path.join(stubs_dir, "unzip"), """
+ #!/bin/sh
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ -d)
+ dest="$2"
+ shift 2
+ ;;
+ *)
+ shift
+ ;;
+ esac
+ done
+
+ mkdir -p "$dest/release/bin"
+ printf 'marker' > "$dest/release/bin/marker"
+ """)
+
+ write_executable(Path.join(stubs_dir, "uname"), """
+ #!/bin/sh
+ printf '%s\n' '#{arch}'
+ """)
+
+ write_executable(Path.join(stubs_dir, "getconf"), getconf_stub(libc))
+
+ write_executable(Path.join(stubs_dir, "ldd"), """
+ #!/bin/sh
+ printf '%s\n' 'musl libc (mock)'
+ """)
+ end
+
+ defp getconf_stub("glibc") do
+ """
+ #!/bin/sh
+ printf '%s\n' 'glibc 2.40'
+ """
+ end
+
+ defp getconf_stub(_libc) do
+ """
+ #!/bin/sh
+ exit 1
+ """
+ end
+
+ defp curl_url(curl_args_path) do
+ ["-fL", url, "-o", _artifact_path] =
+ curl_args_path
+ |> File.read!()
+ |> String.split("\n", trim: true)
+
+ url
+ end
+end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Oct 31, 10:20 AM (12 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1801272
Default Alt Text
(50 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline