Skip to content

Commit e7c6382

Browse files
committed
ci: implement reusable GitHub Actions workflows for CI/CD
- Rename Android CI workflow to android-ci.yml - Create new ci.yml workflow for centralized CI/CD management - Add deploy-tag.yml workflow for handling tag-based releases - Introduce version.yml workflow for version management - Update build.gradle to use jitpack.io repository
1 parent 5ecbe9a commit e7c6382

5 files changed

Lines changed: 229 additions & 32 deletions

File tree

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,7 @@
1-
name: Android CI
1+
name: android-ci
22

33
on:
4-
push:
5-
paths-ignore:
6-
- '**/README.md'
7-
- '**/doc-dev/*'
8-
branches:
9-
- 'main'
10-
- 'release-*'
11-
- '*-feature-*'
12-
- '*-enhancement-*'
13-
- '*-hotfix-*'
14-
- '*-bug-*'
15-
- '*-documentation-*'
16-
- 'BF-*'
17-
- 'FE-*'
18-
- 'PU-*'
19-
- 'DOC-*'
20-
tags:
21-
- '*' # Push events to matching *, i.e. 1.0.0 v1.0, v20.15.10
22-
pull_request:
23-
paths-ignore:
24-
- '**/README.md'
25-
types: # https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#pull_request
26-
- opened
27-
- reopened
28-
- closed
29-
# branches:
30-
# - 'main'
31-
# - 'release-*'
32-
# - 'DOC-*'
33-
# - 'hotfix-*'
4+
workflow_call: # https://docs.github.com/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow
345

356
jobs:
367
build:

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**/README.md'
7+
- '**/doc-dev/*'
8+
branches:
9+
- 'main'
10+
- 'release-*'
11+
- '*-feature-*'
12+
- '*-enhancement-*'
13+
- '*-hotfix-*'
14+
- '*-bug-*'
15+
- '*-documentation-*'
16+
- 'BF-*'
17+
- 'FE-*'
18+
- 'PU-*'
19+
- 'DOC-*'
20+
tags:
21+
- '*' # Push events to matching *, i.e. 1.0.0 v1.0, v20.15.10
22+
pull_request:
23+
paths-ignore:
24+
- '**/README.md'
25+
types: # https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#pull_request
26+
- opened
27+
- reopened
28+
- closed
29+
# branches:
30+
# - 'main'
31+
# - 'release-*'
32+
# - 'DOC-*'
33+
# - 'hotfix-*'
34+
35+
permissions:
36+
contents: write
37+
discussions: write
38+
39+
jobs:
40+
version:
41+
name: version
42+
uses: ./.github/workflows/version.yml
43+
44+
android-ci:
45+
name: android-ci
46+
needs:
47+
- version
48+
uses: ./.github/workflows/android-ci.yml
49+
50+
### tag to release start
51+
52+
deploy-tag:
53+
needs:
54+
- version
55+
- go-goreleaser-by-tag
56+
# - docker-bake-multi-basic-all-tag
57+
# - go-release-platform
58+
name: deploy-tag
59+
uses: ./.github/workflows/deploy-tag.yml
60+
if: startsWith(github.ref, 'refs/tags/')
61+
secrets: inherit
62+
with:
63+
prerelease: true
64+
tag_name: ${{ needs.version.outputs.tag_name }}
65+
tag_changes: ${{ needs.version.outputs.cc_changes }}
66+
# download_artifact_name: android-release
67+
68+
### tag to release end

.github/workflows/deploy-tag.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: deploy-tag
2+
3+
on:
4+
workflow_call: # https://docs.github.com/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow
5+
inputs:
6+
dry_run:
7+
description: 'dry run flag'
8+
default: false
9+
required: false
10+
type: boolean
11+
prerelease:
12+
description: 'prerelease flag'
13+
default: true
14+
required: false
15+
type: boolean
16+
tag_name:
17+
description: 'tag name, if not tag will null'
18+
default: ''
19+
required: false
20+
type: string
21+
tag_changes:
22+
description: 'tag changes, if not tag will null'
23+
default: ''
24+
required: false
25+
type: string
26+
download_artifact_name:
27+
description: 'download artifact name, download from actions/upload-artifact, as: {download_artifact_name}-{tag_name}-*, empty is not download'
28+
default: ''
29+
required: false
30+
type: string
31+
32+
permissions: # https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#permissions
33+
contents: write
34+
discussions: write
35+
36+
jobs:
37+
repo-release:
38+
name: repo-release
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Check inputs
42+
run: |
43+
echo "inputs.dry_run: ${{ inputs.dry_run }}"
44+
echo "inputs.prerelease: ${{ inputs.prerelease }}"
45+
echo "inputs.tag_name: ${{ inputs.tag_name }}"
46+
echo "inputs.download_artifact_name: ${{ inputs.download_artifact_name }}"
47+
48+
- uses: actions/checkout@v4
49+
50+
- name: Check deploy inputs
51+
run: |
52+
echo "prerelease: ${{inputs.prerelease}}"
53+
echo "tag_name: ${{inputs.tag_name}}"
54+
echo "download_artifact_name: ${{inputs.download_artifact_name}}"
55+
56+
- name: Download Artifact
57+
uses: actions/download-artifact@v4
58+
if: ${{ inputs.download_artifact_name != null }}
59+
with:
60+
path: ${{ github.workspace }}/dist
61+
## https://github.com/actions/download-artifact/tree/v4?tab=readme-ov-file#breaking-changes
62+
pattern: ${{ inputs.download_artifact_name }}-${{ github.run_id }}-${{ github.run_attempt }}-${{inputs.tag_name}}*
63+
merge-multiple: true
64+
65+
- name: Display structure of downloaded files
66+
if: ${{ inputs.download_artifact_name != null }}
67+
run: |
68+
ls -R ${{ github.workspace }}/dist
69+
70+
- uses: softprops/action-gh-release@v2
71+
name: Create Release
72+
if: ${{ ! inputs.dry_run }}
73+
with:
74+
tag_name: ${{inputs.tag_name}}
75+
## with permissions to create releases in the other repo
76+
token: "${{ secrets.GITHUB_TOKEN }}"
77+
prerelease: ${{inputs.prerelease}}
78+
body: "${{ inputs.tag_changes }}"
79+
# body_path: ${{ github.workspace }}/CHANGELOG.md
80+
## set release binaries, empty means do not upload files for release
81+
# https://github.com/isaacs/node-glob
82+
files: |
83+
**/*metadata.json
84+
**/*checksums.txt
85+
**/*.zip
86+
**/*.tar.gz
87+
**/*.sha256

.github/workflows/version.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: version
2+
3+
on:
4+
workflow_call: # https://docs.github.com/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow
5+
outputs:
6+
short_sha:
7+
description: 'version short hash of the commit size 8'
8+
value: ${{ jobs.version-check.outputs.short_sha }}
9+
sha:
10+
description: 'version short hash of the commit'
11+
value: ${{ jobs.version-check.outputs.sha }}
12+
tag_name:
13+
description: 'tag name, if not tag will null'
14+
value: ${{ jobs.version-check.outputs.tag_name }}
15+
cc_version:
16+
description: 'conventional version'
17+
value: ${{ jobs.version-check.outputs.cc_version }}
18+
cc_date:
19+
description: 'conventional date'
20+
value: ${{ jobs.version-check.outputs.cc_date }}
21+
cc_changes:
22+
description: 'conventional change logs'
23+
value: ${{ jobs.version-check.outputs.cc_changes }}
24+
cc_status:
25+
description: 'conventional change status, released or prereleased'
26+
value: ${{ jobs.version-check.outputs.cc_status }}
27+
28+
29+
jobs:
30+
version-check:
31+
name: version-check
32+
runs-on: ${{ matrix.os }}
33+
strategy:
34+
matrix:
35+
include:
36+
- build: linux
37+
os: ubuntu-latest
38+
target: x86_64-unknown-linux-gnu
39+
outputs:
40+
short_sha: ${{ steps.check-version.outputs.short-sha }}
41+
sha: ${{ steps.check-version.outputs.sha }}
42+
tag_name: ${{ steps.check-version.outputs.tag-version }}
43+
cc_version: ${{ steps.check-version.outputs.cc-latest-version }}
44+
cc_date: ${{ steps.check-version.outputs.cc-latest-date }}
45+
cc_changes: ${{ steps.check-version.outputs.cc-latest-changes-log }}
46+
cc_status: ${{ steps.check-version.outputs.cc-latest-status }}
47+
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
52+
- name: get version and conventional
53+
id: check-version
54+
uses: convention-change/conventional-version-check@v1.4.0 # or change to latest version
55+
with:
56+
sha-length: 8
57+
58+
- name: check version and conventional
59+
run: |
60+
echo "github.run_id: ${{ github.run_id }}"
61+
echo "github.run_attempt: ${{ github.run_attempt }}"
62+
echo "sha: ${{ steps.check-version.outputs.sha }}"
63+
echo "env SHA-SHORT: ${{ env.SHA-SHORT }}"
64+
echo "short-sha: ${{ steps.check-version.outputs.short-sha }}"
65+
echo "tag-version: ${{ steps.check-version.outputs.tag-version }}"
66+
echo "env GIT_TAG_VERSION: ${{ env.GIT_TAG_VERSION }}"
67+
echo "cc-latest-version: ${{ steps.check-version.outputs.cc-latest-version }}"
68+
echo "cc-latest-date: ${{ steps.check-version.outputs.cc-latest-date }}"
69+
echo "cc-latest-status: ${{ steps.check-version.outputs.cc-latest-status }}"

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ buildscript {
1414
apply from: rootProject.file("config.gradle")
1515

1616
repositories {
17+
mavenLocal()
1718
mavenCentral()
19+
maven { url 'https://jitpack.io' }
1820
google()
1921
}
2022

@@ -40,9 +42,9 @@ allprojects {
4042
// maven { url REPO_SNAPSHOT_REPOSITORY_URL }
4143
// }
4244
// public java and android repository
43-
// maven { url 'https://jitpack.io' }
4445
// maven { url 'https://maven.aliyun.com/repository/public/' }
4546
mavenCentral()
47+
maven { url 'https://jitpack.io' }
4648
google()
4749
}
4850

0 commit comments

Comments
 (0)