Add manual release workflow for peyawallet
This commit is contained in:
@@ -0,0 +1,370 @@
|
||||
name: release
|
||||
run-name: release wallet ${{ inputs.tag_name }}
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag_name:
|
||||
description: Release tag (for example v0.1.0)
|
||||
required: true
|
||||
target_ref:
|
||||
description: Branch, tag or commit to build and tag
|
||||
required: true
|
||||
default: develop
|
||||
peya_release_tag:
|
||||
description: Peya release tag to bundle runtime from
|
||||
required: false
|
||||
default: latest
|
||||
monero_c_release_tag:
|
||||
description: monero_c release tag to bundle runtime from
|
||||
required: false
|
||||
default: latest
|
||||
release_name:
|
||||
description: Optional release title
|
||||
required: false
|
||||
release_notes:
|
||||
description: Release notes / body
|
||||
required: false
|
||||
prerelease:
|
||||
description: Mark release as prerelease
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
draft:
|
||||
description: Create release as draft
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
name: Create release
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
release_id: ${{ steps.release.outputs.release_id }}
|
||||
steps:
|
||||
- name: Install release tooling
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y curl jq
|
||||
|
||||
- name: Create or reuse Gitea release
|
||||
id: release
|
||||
env:
|
||||
PEYAWALLET_GITEA_PAT: ${{ secrets.PEYAWALLET_GITEA_PAT }}
|
||||
PEYA_GITEA_PAT: ${{ secrets.PEYA_GITEA_PAT }}
|
||||
GITEA_PAT: ${{ secrets.GITEA_PAT }}
|
||||
GITEA_API: ${{ github.server_url }}/api/v1
|
||||
REPO: ${{ github.repository }}
|
||||
TAG_NAME: ${{ inputs.tag_name }}
|
||||
INPUT_RELEASE_NAME: ${{ inputs.release_name }}
|
||||
RELEASE_NOTES: ${{ inputs.release_notes }}
|
||||
TARGET_COMMITISH: ${{ inputs.target_ref }}
|
||||
INPUT_PRERELEASE: ${{ inputs.prerelease }}
|
||||
INPUT_DRAFT: ${{ inputs.draft }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
GITEA_TOKEN="${PEYAWALLET_GITEA_PAT:-${PEYA_GITEA_PAT:-${GITEA_PAT:-}}}"
|
||||
if [ -z "${GITEA_TOKEN}" ]; then
|
||||
echo "Missing Gitea PAT secret for release publishing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "${INPUT_RELEASE_NAME}" ]; then
|
||||
RELEASE_NAME="${INPUT_RELEASE_NAME}"
|
||||
else
|
||||
RELEASE_NAME="Peya Wallet ${TAG_NAME}"
|
||||
fi
|
||||
|
||||
get_release_url="${GITEA_API}/repos/${REPO}/releases/tags/${TAG_NAME}"
|
||||
create_release_url="${GITEA_API}/repos/${REPO}/releases"
|
||||
|
||||
status="$(curl -sS -o /tmp/release.json -w '%{http_code}' \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${get_release_url}")"
|
||||
|
||||
if [ "${status}" = "200" ]; then
|
||||
echo "release_id=$(jq -r '.id' /tmp/release.json)" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${status}" != "404" ]; then
|
||||
echo "Unexpected response while checking release: HTTP ${status}"
|
||||
cat /tmp/release.json
|
||||
exit 1
|
||||
fi
|
||||
|
||||
jq -n \
|
||||
--arg tag_name "${TAG_NAME}" \
|
||||
--arg target_commitish "${TARGET_COMMITISH}" \
|
||||
--arg name "${RELEASE_NAME}" \
|
||||
--arg body "${RELEASE_NOTES}" \
|
||||
--argjson draft "${INPUT_DRAFT}" \
|
||||
--argjson prerelease "${INPUT_PRERELEASE}" \
|
||||
'{tag_name:$tag_name,target_commitish:$target_commitish,name:$name,body:$body,draft:$draft,prerelease:$prerelease}' \
|
||||
> /tmp/release-payload.json
|
||||
|
||||
curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-X POST \
|
||||
--data @/tmp/release-payload.json \
|
||||
"${create_release_url}" \
|
||||
-o /tmp/release.json
|
||||
|
||||
if ! jq -e '.id' /tmp/release.json >/dev/null; then
|
||||
cat /tmp/release.json
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "release_id=$(jq -r '.id' /tmp/release.json)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build-linux:
|
||||
name: Build Linux release
|
||||
needs: create-release
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
PEYA_RELEASE_TAG: ${{ inputs.peya_release_tag }}
|
||||
MONERO_C_RELEASE_TAG: ${{ inputs.monero_c_release_tag }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
submodules: false
|
||||
ref: ${{ inputs.target_ref }}
|
||||
|
||||
- name: Configure Gitea auth for monero_c submodule
|
||||
env:
|
||||
PEYAWALLET_GITEA_PAT: ${{ secrets.PEYAWALLET_GITEA_PAT }}
|
||||
PEYA_GITEA_PAT: ${{ secrets.PEYA_GITEA_PAT }}
|
||||
GITEA_PAT: ${{ secrets.GITEA_PAT }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
AUTH_TOKEN="${PEYAWALLET_GITEA_PAT:-${PEYA_GITEA_PAT:-${GITEA_PAT:-}}}"
|
||||
if [ -n "${AUTH_TOKEN}" ]; then
|
||||
git config --global url."http://tiamak:${AUTH_TOKEN}@54.38.205.168:3000/".insteadOf "http://54.38.205.168:3000/"
|
||||
fi
|
||||
git submodule sync
|
||||
git -c protocol.version=2 submodule update --init --force monero_c
|
||||
|
||||
- name: Install Linux build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libayatana-appindicator3-dev \
|
||||
clang \
|
||||
cmake \
|
||||
curl \
|
||||
jq \
|
||||
libgtk-3-dev \
|
||||
liblzma-dev \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
python3 \
|
||||
tar \
|
||||
xz-utils
|
||||
|
||||
- name: Setup Flutter
|
||||
uses: https://github.com/subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
|
||||
- name: Stage runtime from releases
|
||||
env:
|
||||
PEYAWALLET_GITEA_PAT: ${{ secrets.PEYAWALLET_GITEA_PAT }}
|
||||
PEYA_GITEA_PAT: ${{ secrets.PEYA_GITEA_PAT }}
|
||||
MONERO_C_GITEA_PAT: ${{ secrets.MONERO_C_GITEA_PAT }}
|
||||
GITEA_PAT: ${{ secrets.GITEA_PAT }}
|
||||
run: |
|
||||
python3 scripts/ci/stage_release_runtime.py \
|
||||
--platform linux \
|
||||
--peya-tag "${PEYA_RELEASE_TAG:-latest}" \
|
||||
--monero-c-tag "${MONERO_C_RELEASE_TAG:-latest}" \
|
||||
--repo-root .
|
||||
|
||||
- name: Fetch Dart/Flutter deps
|
||||
run: |
|
||||
flutter pub get
|
||||
|
||||
- name: Build Linux release
|
||||
run: |
|
||||
flutter build linux --release
|
||||
|
||||
- name: Package Linux release
|
||||
env:
|
||||
TAG_NAME: ${{ inputs.tag_name }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
archive="/tmp/peyawallet-${TAG_NAME}-linux-x86_64.tar.gz"
|
||||
tar -C build/linux/x64/release/bundle -czf "${archive}" .
|
||||
echo "ARCHIVE_PATH=${archive}" >> "$GITHUB_ENV"
|
||||
echo "ARCHIVE_NAME=$(basename "${archive}")" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Upload Linux release asset
|
||||
env:
|
||||
PEYAWALLET_GITEA_PAT: ${{ secrets.PEYAWALLET_GITEA_PAT }}
|
||||
PEYA_GITEA_PAT: ${{ secrets.PEYA_GITEA_PAT }}
|
||||
GITEA_PAT: ${{ secrets.GITEA_PAT }}
|
||||
GITEA_API: ${{ github.server_url }}/api/v1
|
||||
REPO: ${{ github.repository }}
|
||||
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
|
||||
ARCHIVE_PATH: ${{ env.ARCHIVE_PATH }}
|
||||
ARCHIVE_NAME: ${{ env.ARCHIVE_NAME }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
GITEA_TOKEN="${PEYAWALLET_GITEA_PAT:-${PEYA_GITEA_PAT:-${GITEA_PAT:-}}}"
|
||||
if [ -z "${GITEA_TOKEN}" ]; then
|
||||
echo "Missing Gitea PAT secret for release publishing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
assets_url="${GITEA_API}/repos/${REPO}/releases/${RELEASE_ID}/assets"
|
||||
curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${assets_url}" \
|
||||
-o /tmp/release-assets.json
|
||||
|
||||
existing_id="$(jq -r --arg name "${ARCHIVE_NAME}" '.[] | select(.name == $name) | .id' /tmp/release-assets.json | head -n 1)"
|
||||
if [ -n "${existing_id}" ]; then
|
||||
curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-X DELETE \
|
||||
"${assets_url}/${existing_id}" \
|
||||
>/dev/null
|
||||
fi
|
||||
|
||||
curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-X POST \
|
||||
-F "attachment=@${ARCHIVE_PATH}" \
|
||||
"${assets_url}?name=${ARCHIVE_NAME}" \
|
||||
>/dev/null
|
||||
|
||||
build-windows:
|
||||
name: Build Windows release
|
||||
needs: create-release
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
PEYA_RELEASE_TAG: ${{ inputs.peya_release_tag }}
|
||||
MONERO_C_RELEASE_TAG: ${{ inputs.monero_c_release_tag }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
submodules: false
|
||||
ref: ${{ inputs.target_ref }}
|
||||
|
||||
- name: Configure Gitea auth for monero_c submodule
|
||||
shell: bash
|
||||
env:
|
||||
PEYAWALLET_GITEA_PAT: ${{ secrets.PEYAWALLET_GITEA_PAT }}
|
||||
PEYA_GITEA_PAT: ${{ secrets.PEYA_GITEA_PAT }}
|
||||
GITEA_PAT: ${{ secrets.GITEA_PAT }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
AUTH_TOKEN="${PEYAWALLET_GITEA_PAT:-${PEYA_GITEA_PAT:-${GITEA_PAT:-}}}"
|
||||
if [ -n "${AUTH_TOKEN}" ]; then
|
||||
git config --global url."http://tiamak:${AUTH_TOKEN}@54.38.205.168:3000/".insteadOf "http://54.38.205.168:3000/"
|
||||
fi
|
||||
git submodule sync
|
||||
git -c protocol.version=2 submodule update --init --force monero_c
|
||||
|
||||
- name: Stage runtime from releases
|
||||
shell: bash
|
||||
env:
|
||||
PEYAWALLET_GITEA_PAT: ${{ secrets.PEYAWALLET_GITEA_PAT }}
|
||||
PEYA_GITEA_PAT: ${{ secrets.PEYA_GITEA_PAT }}
|
||||
MONERO_C_GITEA_PAT: ${{ secrets.MONERO_C_GITEA_PAT }}
|
||||
GITEA_PAT: ${{ secrets.GITEA_PAT }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python -u scripts/ci/stage_release_runtime.py \
|
||||
--platform windows \
|
||||
--peya-tag "${PEYA_RELEASE_TAG:-latest}" \
|
||||
--monero-c-tag "${MONERO_C_RELEASE_TAG:-latest}" \
|
||||
--repo-root .
|
||||
|
||||
- name: Show toolchain
|
||||
shell: bash
|
||||
run: |
|
||||
flutter doctor -v
|
||||
|
||||
- name: Fetch Dart/Flutter deps
|
||||
shell: bash
|
||||
run: |
|
||||
flutter pub get
|
||||
|
||||
- name: Build Windows release
|
||||
shell: bash
|
||||
run: |
|
||||
flutter build windows --release
|
||||
|
||||
- name: Package Windows release
|
||||
shell: bash
|
||||
env:
|
||||
TAG_NAME: ${{ inputs.tag_name }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
archive="C:/Windows/Temp/peyawallet-${TAG_NAME}-windows-x86_64.zip"
|
||||
powershell.exe -NoProfile -Command "if (Test-Path '${archive}') { Remove-Item '${archive}' -Force }; Compress-Archive -Path 'build/windows/x64/runner/Release/*' -DestinationPath '${archive}'"
|
||||
echo "ARCHIVE_PATH=${archive}" >> "$GITHUB_ENV"
|
||||
echo "ARCHIVE_NAME=$(basename "${archive}")" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Upload Windows release asset
|
||||
shell: bash
|
||||
env:
|
||||
PEYAWALLET_GITEA_PAT: ${{ secrets.PEYAWALLET_GITEA_PAT }}
|
||||
PEYA_GITEA_PAT: ${{ secrets.PEYA_GITEA_PAT }}
|
||||
GITEA_PAT: ${{ secrets.GITEA_PAT }}
|
||||
GITEA_API: ${{ github.server_url }}/api/v1
|
||||
REPO: ${{ github.repository }}
|
||||
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
|
||||
ARCHIVE_PATH: ${{ env.ARCHIVE_PATH }}
|
||||
ARCHIVE_NAME: ${{ env.ARCHIVE_NAME }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
GITEA_TOKEN="${PEYAWALLET_GITEA_PAT:-${PEYA_GITEA_PAT:-${GITEA_PAT:-}}}"
|
||||
if [ -z "${GITEA_TOKEN}" ]; then
|
||||
echo "Missing Gitea PAT secret for release publishing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
assets_url="${GITEA_API}/repos/${REPO}/releases/${RELEASE_ID}/assets"
|
||||
curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${assets_url}" \
|
||||
-o release-assets.json
|
||||
|
||||
existing_id="$(python - <<'PY'
|
||||
import json
|
||||
import os
|
||||
|
||||
name = os.environ['ARCHIVE_NAME']
|
||||
with open('release-assets.json', 'r', encoding='utf-8') as fh:
|
||||
data = json.load(fh)
|
||||
|
||||
for item in data:
|
||||
if item.get('name') == name:
|
||||
print(item.get('id', ''))
|
||||
break
|
||||
PY
|
||||
)"
|
||||
if [ -n "${existing_id}" ]; then
|
||||
curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-X DELETE \
|
||||
"${assets_url}/${existing_id}" \
|
||||
>/dev/null
|
||||
fi
|
||||
|
||||
curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-X POST \
|
||||
-F "attachment=@${ARCHIVE_PATH}" \
|
||||
"${assets_url}?name=${ARCHIVE_NAME}" \
|
||||
>/dev/null
|
||||
Reference in New Issue
Block a user