Skip to content

Commit a518cd0

Browse files
committed
chore: release with source zip
1 parent 156ce4e commit a518cd0

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
tags:
55
- '*'
66
workflow_dispatch:
7+
8+
env:
9+
DIST_ARCHIVE_PREFIX_NAME: ${{ github.event.repository.name }}
10+
SOURCE_ARCHIVE_NAME: ${{ github.event.repository.name }}
11+
712
jobs:
813
# lint-and-test:
914
# runs-on: ubuntu-latest
@@ -22,6 +27,7 @@ jobs:
2227
# - name: Install dependencies
2328
# run: |
2429
# yarn
30+
2531
build-android-apk:
2632
name: Build Android APK
2733
if: startsWith(github.ref, 'refs/tags/')
@@ -33,6 +39,23 @@ jobs:
3339
steps:
3440
- name: Checkout
3541
uses: actions/checkout@v2
42+
- name: Get the version
43+
id: get_version
44+
run: |
45+
echo ::set-output name=PACKAGE_VERSION_NAME::$(node -p "require('./package.json').version")
46+
echo ::set-output name=COMMIT_ID::$(echo ${{ github.sha }} | cut -c1-7)
47+
- name: Set name
48+
id: set_name
49+
run: |
50+
echo ::set-output name=APK_NAME::$(echo "${{ env.DIST_ARCHIVE_PREFIX_NAME }}-${{ steps.get_version.outputs.PACKAGE_VERSION_NAME }}-${{ steps.get_version.outputs.COMMIT_ID }}.apk")
51+
echo ::set-output name=SOURCE_ZIP_NAME::$(echo "${{ env.SOURCE_ARCHIVE_NAME }}-${{ steps.get_version.outputs.PACKAGE_VERSION_NAME }}-${{ steps.get_version.outputs.COMMIT_ID }}.zip")
52+
- name: Archive source code
53+
uses: papeloto/action-zip@v1
54+
with:
55+
files: |
56+
./
57+
recursive: false
58+
dest: ${{ steps.set_name.outputs.SOURCE_ZIP_NAME }}
3659
- name: Use Node.js
3760
uses: actions/setup-node@v2
3861
with:
@@ -50,17 +73,8 @@ jobs:
5073
- name: Build android apk
5174
run: |
5275
cd android && ./gradlew assembleRelease
53-
- name: Get the version
54-
id: get_version
55-
run: |
56-
echo ::set-output name=PACKAGE_VERSION_NAME::$(node -p "require('./package.json').version")
57-
echo ::set-output name=COMMIT_ID::$(echo ${{ github.sha }} | cut -c1-7)
58-
- name: Set apk name
59-
id: set_apk_name
60-
run: |
61-
echo ::set-output name=APK_NAME::$(echo "v2hub-${{ steps.get_version.outputs.PACKAGE_VERSION_NAME }}-${{ steps.get_version.outputs.COMMIT_ID }}.apk")
6276
- name: Move release apk to target directory
63-
run: cp android/app/build/outputs/apk/release/app-release.apk android/app/build/outputs/apk/release/${{ steps.set_apk_name.outputs.APK_NAME }}
77+
run: cp android/app/build/outputs/apk/release/app-release.apk android/app/build/outputs/apk/release/${{ steps.set_name.outputs.APK_NAME }}
6478
- name: Build changelog
6579
id: build_changelog
6680
uses: mikepenz/[email protected]
@@ -74,7 +88,8 @@ jobs:
7488
with:
7589
body: ${{steps.build_changelog.outputs.changelog}}
7690
files: |
77-
android/app/build/outputs/apk/release/${{ steps.set_apk_name.outputs.APK_NAME }}
91+
android/app/build/outputs/apk/release/${{ steps.set_name.outputs.APK_NAME }}
92+
${{ steps.set_name.outputs.SOURCE_ZIP_NAME }}
7893
env:
7994
GITHUB_TOKEN: ${{ secrets.github_token }}
8095

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "react-native-v2ex",
2+
"name": "v2hub",
33
"version": "0.8.1",
44
"description": "This project used React Native to build a V2EX mobile client application. The main goal was to build a React Native rapid development scaffold.",
55
"main": "index.js",

0 commit comments

Comments
 (0)