132 lines
3.3 KiB
YAML
132 lines
3.3 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
- "release-*"
|
|
- "[0-9]+.[0-9]+.[0-9]+*"
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
GO_VERSION: "1.26.0"
|
|
ANDROID_SDK_ROOT: /opt/android-sdk
|
|
ANDROID_NDK_ROOT: /opt/android-ndk
|
|
JAVA_HOME: /usr/lib/jvm/java-25-openjdk
|
|
DIST_DIR: dist
|
|
|
|
jobs:
|
|
lint-test:
|
|
runs-on:
|
|
- self-hosted
|
|
- linux
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Lint
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
state_dir="$(mktemp -d)"
|
|
trap 'rm -rf -- "$state_dir"' EXIT
|
|
KEEPASSGO_STATE_DIR="$state_dir" go tool golangci-lint run
|
|
|
|
- name: Test
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
state_dir="$(mktemp -d)"
|
|
trap 'rm -rf -- "$state_dir"' EXIT
|
|
KEEPASSGO_STATE_DIR="$state_dir" go test ./...
|
|
|
|
build:
|
|
needs: lint-test
|
|
runs-on:
|
|
- self-hosted
|
|
- linux
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Prepare dist directory
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
mkdir -p "${DIST_DIR}"
|
|
|
|
- name: Build desktop binaries
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
for target in \
|
|
"linux amd64" \
|
|
"linux arm64" \
|
|
"windows amd64" \
|
|
"windows arm64"
|
|
do
|
|
set -- ${target}
|
|
goos="$1"
|
|
goarch="$2"
|
|
ext=""
|
|
if [[ "${goos}" == "windows" ]]; then
|
|
ext=".exe"
|
|
fi
|
|
out="${DIST_DIR}/keepassgo-${goos}-${goarch}${ext}"
|
|
GOOS="${goos}" GOARCH="${goarch}" CGO_ENABLED=0 go build -o "${out}" .
|
|
done
|
|
|
|
- name: Build APK
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
make apk
|
|
cp build/keepassgo.apk "${DIST_DIR}/keepassgo.apk"
|
|
|
|
- name: Upload CI artifacts
|
|
uses: christopherhx/gitea-upload-artifact@v4
|
|
with:
|
|
name: keepassgo-${{ gitea.sha }}
|
|
path: |
|
|
dist/keepassgo-linux-amd64
|
|
dist/keepassgo-linux-arm64
|
|
dist/keepassgo-windows-amd64.exe
|
|
dist/keepassgo-windows-arm64.exe
|
|
dist/keepassgo.apk
|
|
retention-days: 30
|
|
|
|
- name: Publish release artifacts
|
|
if: startsWith(gitea.ref, 'refs/tags/')
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
|
GITEA_REF_NAME: ${{ gitea.ref_name }}
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
python3 scripts/gitea_release.py \
|
|
--server "${GITEA_SERVER_URL}" \
|
|
--repo "${GITEA_REPOSITORY}" \
|
|
--token "${GITEA_TOKEN}" \
|
|
--tag "${GITEA_REF_NAME}" \
|
|
"${DIST_DIR}/keepassgo-linux-amd64" \
|
|
"${DIST_DIR}/keepassgo-linux-arm64" \
|
|
"${DIST_DIR}/keepassgo-windows-amd64.exe" \
|
|
"${DIST_DIR}/keepassgo-windows-arm64.exe" \
|
|
"${DIST_DIR}/keepassgo.apk"
|