-
Notifications
You must be signed in to change notification settings - Fork 4
110 lines (102 loc) · 3.91 KB
/
Copy pathgitcode-backfill.yml
File metadata and controls
110 lines (102 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: GitCode Mirror Backfill
# 手动把某个已发布 tag 同步到 GitCode 镜像仓库(真 APK + release notes)。
# 用途:1) 发版链路联调;2) 补建历史 Release(正常发版的自动同步在 android-build.yml)。
# 依赖 Variable GITCODE_USERNAME(不存在时同步 job 自动跳过)、可选 Variable GITCODE_REPOSITORY、Secret GITCODE_TOKEN。
on:
workflow_dispatch:
inputs:
tag:
description: '要同步的 GitHub tag,如 v2.1.1.4'
required: true
type: string
skip_push:
description: '跳过代码推送(目标是 GitCode 镜像仓库时用,GitCode 自己同步代码)'
required: false
type: boolean
default: false
concurrency:
group: gitcode-backfill-${{ inputs.tag }}
cancel-in-progress: false
jobs:
prepare:
name: Prepare APK and release notes
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
prerelease: ${{ steps.meta.outputs.prerelease }}
body: ${{ steps.meta.outputs.body }}
steps:
- name: Checkout at tag
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ inputs.tag }}
- name: Download release APK from GitHub
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -ex
mkdir -p dist
gh release download "${{ inputs.tag }}" --repo "${{ github.repository }}" --pattern 'mikcb-*.apk' --dir dist
ls -lh dist
- name: Extract release notes and channel
id: meta
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -ex
TAG="${{ inputs.tag }}"
VERSION_NAME="${TAG#v}"
NOTES_FILE="docs/releases/v${VERSION_NAME}.md"
if [[ -f "${NOTES_FILE}" ]]; then
cp "${NOTES_FILE}" /tmp/body.md
else
gh release view "${TAG}" --repo "${{ github.repository }}" --json body --jq .body > /tmp/body.md
fi
# 应用内 GitCode 渠道的完整性校验依赖正文内嵌摘要(GitCode 无 asset digest)
SHA256=$(sha256sum dist/mikcb-*.apk | awk '{print $1}')
{
echo ""
echo "---"
echo "SHA-256: ${SHA256}"
} >> /tmp/body.md
echo "body<<EOF" >> "$GITHUB_OUTPUT"
cat /tmp/body.md >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
PRERELEASE=$(gh release view "${TAG}" --repo "${{ github.repository }}" --json isPrerelease --jq .isPrerelease)
echo "prerelease=${PRERELEASE}" >> "$GITHUB_OUTPUT"
- name: Upload APK artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: android-release-apk
path: dist/mikcb-*.apk
gitcode-push:
name: Push code to GitCode
if: ${{ vars.GITCODE_USERNAME && !inputs.skip_push }}
needs: prepare
permissions:
contents: read
uses: nvdacn/sync_to_gitcode/.github/workflows/PushToGitCode.yaml@18b70112d0e62260bc54085028e5510bbc6323b2 # sync_to_gitcode@master
with:
default_branch: main
gitcode_username: ${{ vars.GITCODE_USERNAME }}
secrets:
GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }}
gitcode-release:
name: Release APK on GitCode
if: ${{ !cancelled() && needs.prepare.result == 'success' && vars.GITCODE_USERNAME }}
needs: [prepare, gitcode-push]
permissions:
actions: read
uses: nvdacn/sync_to_gitcode/.github/workflows/CreateReleaseOnGitCode.yaml@18b70112d0e62260bc54085028e5510bbc6323b2 # sync_to_gitcode@master
with:
artifact_name: android-release-apk
default_branch: main
tag_name: ${{ inputs.tag }}
body: ${{ needs.prepare.outputs.body }}
prerelease: ${{ needs.prepare.outputs.prerelease == 'true' }}
file_name: 'mikcb-*.apk'
secrets:
GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }}