Move to woodpecker CI (#1104)

Addresses https://codeberg.org/gitnex/GitNex/issues/1099

@mmarif you would have to enable the repo on woodpecker and disable on gitlab... If you don't think this is a good idea, just close it.

Required secrets: `BOT_TOKEN`, `KS_PASS`, `KEY_PASS`, `KS_REPO`, `WEBDAV_PASSWORD`, `CROWDIN_TOKEN`

We can easily extend this later to run linters and such things.

Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: 6543 <6543@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1104
Reviewed-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
qwerty287 2022-05-13 19:35:09 +02:00 committed by M M Arif
parent fd3e6434dc
commit 43b1a3907d
7 changed files with 65 additions and 265 deletions

View File

@ -1,104 +0,0 @@
---
kind: pipeline
type: docker
name: tests
steps:
- name: unit-tests
image: nextcloudci/android:android-49
depends_on: [ clone ]
commands:
- ./gradlew test
- name: check-formatting
image: zosiab/eclint:latest
depends_on: [ clone ]
commands:
- git pull origin main
- eclint check $(git diff --name-only origin/main)
# This may be used in the future, because it makes of intellij's native code inspection/formatting capabilities.
# Additional information: https://www.jetbrains.com/help/idea/command-line-formatter.html
#
# - name: do-or-check-formatting
# image: dlsniper/docker-intellij
# depends_on: [ clone ]
# commands:
# - /opt/intellij/bin/idea.sh inspect/format ...
#
# - name: do-or-check-formatting
# image: dlsniper/docker-intellij
# depends_on: [ clone ]
# commands:
# - /opt/intellij/bin/idea.sh format -s .idea/codeStyles/Project.xml -m *.java app/src/main/java
trigger:
event:
- pull_request
---
kind: pipeline
type: docker
name: code-analysis
steps:
- name: check-global-formatting
image: zosiab/eclint:latest
depends_on: [ clone ]
commands:
- eclint check $(git ls-files)
trigger:
event:
- push
branch:
- main
---
kind: pipeline
type: docker
name: build
steps:
- name: build
image: nextcloudci/android:android-49
commands:
- ./gradlew assembleFreeRelease
- name: sign
image: nextcloudci/android:android-49
environment:
BOT_TOKEN:
from_secret: BOT_TOKEN
KS_PASS:
from_secret: KS_PASS
KEY_PASS:
from_secret: KEY_PASS
OUTPUT: signed.apk
INSTANCE: https://codeberg.org
KS_FILE: ci_keystore.jks
KS_REPO:
from_secret: KS_REPO
commands:
- ./scripts/sign-build.sh
- name: publish
image: vividboarder/drone-webdav
environment:
WEBDAV_USERNAME: GitNexBot
WEBDAV_PASSWORD:
from_secret: NC_TOKEN
PLUGIN_FILE: 'signed.apk'
PLUGIN_TIMEOUT: 180
PLUGIN_ATTEMPTS: 5
PLUGIN_DESTINATION: 'https://cloud.swatian.com/remote.php/dav/files/GitNexBot/gitnex/builds/latest.apk'
PLUGIN_CUSTOM_ARGUMENTS: '--progress-bar'
trigger:
event:
- push
branch:
- main

View File

@ -1,116 +0,0 @@
stages:
- build
- sign
- publish
- locales
on_setup:
image: curlimages/curl:7.77.0
stage: .pre
only:
- main
- tags
variables:
INSTANCE: "https://codeberg.org"
MAIN_REPO: gitnex/GitNex
STATE: pending
script:
- ./scripts/add-commit-status.sh
build:
image: alvrme/alpine-android:android-31-jdk11
stage: build
only:
- main
- tags
script:
- ./gradlew assembleFreeRelease
artifacts:
paths:
- app/build/outputs/
expire_in: 15 minutes
sign:
image: alvrme/alpine-android:android-31-jdk11
stage: sign
only:
- main
- tags
variables:
OUTPUT: "signed.apk"
INSTANCE: "https://codeberg.org"
KS_FILE: "ci_keystore.jks"
script:
- ./scripts/sign-build.sh
artifacts:
paths:
- signed.apk
expire_in: 15 minutes
latest:
image: curlimages/curl:7.77.0
stage: publish
only:
- main
- tags
variables:
WEBDAV_USERNAME: "GitNexBot"
PLUGIN_FILE: "signed.apk"
PLUGIN_DESTINATION: "https://cloud.swatian.com/remote.php/dav/files/GitNexBot/gitnex/builds/latest.apk"
script:
- curl -T "$PLUGIN_FILE" -u "$WEBDAV_USERNAME":"$WEBDAV_PASSWORD" "$PLUGIN_DESTINATION"
release:
image: curlimages/curl:7.77.0
stage: publish
only:
- tags
variables:
WEBDAV_USERNAME: "GitNexBot"
PLUGIN_FILE: "signed.apk"
script:
- "[[ $CI_COMMIT_REF_NAME == *'-rc'* ]] && echo 'Upload blocked. Build seems to be a release candidate.' && exit 0"
- curl -T "$PLUGIN_FILE" -u "$WEBDAV_USERNAME":"$WEBDAV_PASSWORD" 'https://cloud.swatian.com/remote.php/dav/files/GitNexBot/gitnex/releases/'"$CI_COMMIT_REF_NAME"'.apk'
push_translations:
image: crowdin/cli:3.7.8
stage: locales
only:
refs:
- main
changes:
- app/src/main/res/values/strings.xml
script:
- echo "Set up Crowdin CLI"
- cp crowdin.example.yml crowdin.yml
- sed -i 's/-removed-/'"$CROWDIN_TOKEN"'/' crowdin.yml
- echo "Push translations"
- crowdin push
on_success:
image: curlimages/curl:7.77.0
stage: .post
only:
- main
- tags
variables:
INSTANCE: "https://codeberg.org"
MAIN_REPO: gitnex/GitNex
STATE: success
script:
- ./scripts/add-commit-status.sh
when: on_success
on_failure:
image: curlimages/curl:7.77.0
stage: .post
only:
- main
- tags
variables:
INSTANCE: "https://codeberg.org"
MAIN_REPO: gitnex/GitNex
STATE: failure
script:
- ./scripts/add-commit-status.sh
when: on_failure

52
.woodpecker/build.yml Normal file
View File

@ -0,0 +1,52 @@
pipeline:
build:
image: alvrme/alpine-android:android-31-jdk11
commands:
- ./gradlew assembleFreeRelease
when:
path: [ app/, build.gradle ]
sign:
image: alvrme/alpine-android:android-31-jdk11
environment:
OUTPUT: "signed.apk"
INSTANCE: "https://codeberg.org"
KS_FILE: "gitnex_ci_keystore.jks"
commands:
- >
KEYFILE=$(mktemp)
curl -X GET "${INSTANCE}/api/v1/repos/${KS_REPO}/contents/${KS_FILE}?token=${BOT_TOKEN}" -H "accept: application/json" | sed 's|"content":"|#|g' | cut -d '#' -f 2 | cut -d '"' -f 1 | base64 -d > ${KEYFILE}
apksigner sign -v --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias GitNexBot --ks ${KEYFILE} --out signed.apk $(find . -name "*release*.apk")
secrets: [ BOT_TOKEN, KS_PASS, KEY_PASS, KS_REPO ]
when:
event: [ push, tag ]
branch: main
path: [ app/, build.gradle ]
upload:
image: curlimages/curl:7.82.0
group: upload
environment:
WEBDAV_USERNAME: "GitNexBot"
PLUGIN_FILE: "signed.apk"
PLUGIN_DESTINATION: "https://cloud.swatian.com/remote.php/dav/files/GitNexBot/gitnex/builds/latest.apk"
commands:
- curl -T "$PLUGIN_FILE" -u "$WEBDAV_USERNAME":"$WEBDAV_PASSWORD" "$PLUGIN_DESTINATION"
secrets: [ WEBDAV_PASSWORD ]
when:
event: [ push, tag ]
branch: main
path: [ app/, build.gradle ]
upload-release:
image: curlimages/curl:7.82.0
group: upload
environment:
WEBDAV_USERNAME: "GitNexBot"
PLUGIN_FILE: "signed.apk"
commands:
- "[[ $CI_COMMIT_TAG == *'-rc'* ]] && echo 'Upload blocked. Build seems to be a release candidate.' && exit 0"
- curl -T "$PLUGIN_FILE" -u "$WEBDAV_USERNAME":"$WEBDAV_PASSWORD" 'https://cloud.swatian.com/remote.php/dav/files/GitNexBot/gitnex/releases/'"$CI_COMMIT_TAG"'.apk'
secrets: [ WEBDAV_PASSWORD ]
when:
event: [ tag ]

12
.woodpecker/locale.yml Normal file
View File

@ -0,0 +1,12 @@
pipeline:
push:
image: crowdin/cli:3.7.8
commands:
- cp crowdin.example.yml crowdin.yml
- sed -i 's/-removed-/'"$CROWDIN_TOKEN"'/' crowdin.yml
- crowdin push
secrets: [ CROWDIN_TOKEN ]
when:
event: [ push, tag ]
branch: main
path: [ app/src/main/res/values/strings.xml ]

View File

@ -1,4 +1,4 @@
[![License: GPL v3](https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/license.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Pipeline status](https://img.shields.io/gitlab/pipeline/mmarif4u/gitnex-ci/main)](https://gitlab.com/mmarif4u/gitnex-ci/-/pipelines) [![Release](https://img.shields.io/badge/dynamic/json.svg?label=release&url=https://codeberg.org/api/v1/repos/gitnex/GitNex/releases&query=$[0].tag_name)](https://codeberg.org/gitnex/GitNex/releases) [![Crowdin](https://badges.crowdin.net/gitnex/localized.svg)](https://crowdin.com/project/gitnex) [![Join the Discord chat at https://discord.gg/FbSS4rf](https://img.shields.io/discord/632219664587685908.svg)](https://discord.gg/FbSS4rf)
[![License: GPL v3](https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/license.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Pipeline status](https://ci.codeberg.org/api/badges/gitnex/GitNex/status.svg)](https://ci.codeberg.org/gitnex/GitNex) [![Release](https://img.shields.io/badge/dynamic/json.svg?label=release&url=https://codeberg.org/api/v1/repos/gitnex/GitNex/releases&query=$[0].tag_name)](https://codeberg.org/gitnex/GitNex/releases) [![Crowdin](https://badges.crowdin.net/gitnex/localized.svg)](https://crowdin.com/project/gitnex) [![Join the Discord chat at https://discord.gg/FbSS4rf](https://img.shields.io/discord/632219664587685908.svg)](https://discord.gg/FbSS4rf)
[<img alt="Become a Patreon" src="https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/patreon.png" height="40"/>](https://www.patreon.com/mmarif) [<img alt="Buy me a coffee" src="https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/buy-me-a-coffee.png" height="40"/>](https://www.buymeacoffee.com/mmarif)

View File

@ -1,29 +0,0 @@
#!/bin/sh
# Environment variables which have to be set in order for this to work properly
# @author opyale
#
# INSTANCE (e.g. https://codeberg.org)
# MAIN_REPO (e.g. gitnex/GitNex)
# STATE (e.g. pending, success, error, failure or warning)
# CI_COMMIT_SHA; BOT_TOKEN
context="GitLab CI"
description="GitLab continuous integration tool"
state=$STATE
target_url=$CI_PIPELINE_URL
body='
{
"context": "'$context'",
"description": "'$description'",
"state": "'$state'",
"target_url": "'$target_url'"
}
'
curl --request POST \
--data "$body" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
"${INSTANCE}/api/v1/repos/${MAIN_REPO}/statuses/${CI_COMMIT_SHA}?token=${BOT_TOKEN}"

View File

@ -1,15 +0,0 @@
#!/usr/bin/env bash
# Make sure needed var's are here
[ -z "${BOT_TOKEN}" ] && { echo "Token is missing (BOT_TOKEN)"; exit 1; }
[ -z "${KS_PASS}" ] && { echo "Missing keystore password (KS_PASS)"; exit 1; }
[ -z "${KEY_PASS}" ] && { echo "Missing KEY_PASS"; exit 1; }
[ -z "${INSTANCE}" ] && { echo "Instance url is missing (INSTANCE)"; exit 1; }
[ -z "${KS_REPO}" ] && { echo "Missing repo of keystore (KS_REPO)"; exit 1; }
[ -z "${KS_FILE}" ] && { echo "Filename of keystore is missing (KS_FILE)"; exit 1; }
[ -z "${OUTPUT}" ] && { echo "Missing filename of signed output (OUTPUT)"; exit 1; }
KEYFILE=$(mktemp)
curl -X GET "${INSTANCE}/api/v1/repos/${KS_REPO}/contents/${KS_FILE}?token=${BOT_TOKEN}" -H "accept: application/json" | sed 's|"content":"|#|g' | cut -d '#' -f 2 | cut -d '"' -f 1 | base64 -d > ${KEYFILE}
apksigner sign -v --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias GitNexBot --ks ${KEYFILE} --out signed.apk $(find . -name "*release*.apk")