Skip to content

Commit 835c552

Browse files
committed
feat: add trn release action
1 parent fb3d6be commit 835c552

File tree

13 files changed

+34729
-512
lines changed

13 files changed

+34729
-512
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
npm install
1616
- run: |
1717
npm run all
18-
test: # make sure the action works on a clean machine without building
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v2
22-
- uses: ./
23-
with:
24-
milliseconds: 1000
18+
# test: # make sure the action works on a clean machine without building
19+
# runs-on: ubuntu-latest
20+
# steps:
21+
# - uses: actions/checkout@v2
22+
# - uses: ./
23+
# with:
24+
# token: ${{ secrets.GITHUB_TOKEN }}

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"printWidth": 80,
2+
"printWidth": 180,
33
"tabWidth": 2,
44
"useTabs": false,
55
"semi": false,

README.md

Lines changed: 48 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,56 @@
1-
<p align="center">
2-
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
3-
</p>
4-
5-
# Create a JavaScript Action using TypeScript
6-
7-
Use this template to bootstrap the creation of a TypeScript action.:rocket:
8-
9-
This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance.
10-
11-
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
12-
13-
## Create an action from this template
14-
15-
Click the `Use this Template` and provide the new repo details for your action
16-
17-
## Code in Main
18-
19-
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance.
20-
21-
Install the dependencies
22-
```bash
23-
$ npm install
1+
# Github action for bundle taro react native project
2+
3+
Use this action to package your [Taro React Native](https://docs.taro.zone/) project and generate bundles for Android and iOS. Others can use [Taro Playground APP](https://github.com/wuba/taro-playground) to load the bundle for project preview.
4+
5+
Make it easier to share your ideas.
6+
7+
**Note:** Your React Native version and dependencies must be compatible with the [Taro Playground APP](https://github.com/wuba/taro-playground/blob/main/package.json).
8+
## Workflow
9+
10+
1. Execute `yarn build:rn` to build the bundle.
11+
2. Generate a [Taro Playground APP](https://github.com/wuba/taro-playground) protocol, including platform, name, logo and bundle url.
12+
3. Export the protocol to a file with a QR code.
13+
4. Commit the changes.
14+
5. If `GITHUB_REF_NAME` is tag
15+
1. Delete the original tag and re-tag it.
16+
2. Generate a release, including the QR code and other information.
17+
6. If `GITHUB_REF_NAME` is branch
18+
1. Push the changes to the branch.
19+
20+
## Usage
21+
22+
### Basic Config
23+
24+
```yml
25+
on:
26+
push:
27+
tags: [ v* ]
28+
workflow_dispatch:
29+
30+
jobs:
31+
taro_release_job:
32+
runs-on: ubuntu-latest
33+
name: Taro Bundle Release
34+
steps:
35+
- name: Release Taro React Native bundle
36+
uses: zhiqingchen/taro-react-native-release@v1
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
appname: Taro-Mortgage-calculator
40+
logo: https://pic3.58cdn.com.cn/nowater/fangfe/n_v25b1523466b894881b9bdeda7618a8af2.png
2441
```
2542
26-
Build the typescript and package it for distribution
27-
```bash
28-
$ npm run build && npm run package
29-
```
30-
31-
Run the tests :heavy_check_mark:
32-
```bash
33-
$ npm test
34-
35-
PASS ./index.test.js
36-
✓ throws invalid number (3ms)
37-
wait 500 ms (504ms)
38-
test runs (95ms)
39-
40-
...
41-
```
42-
43-
## Change action.yml
44-
45-
The action.yml defines the inputs and output for your action.
46-
47-
Update the action.yml with your name, description, inputs and outputs for your action.
43+
### Options
4844
49-
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
45+
see [action.yml](./action.yml) for details.
5046
51-
## Change the Code
47+
### Examples
5248
53-
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
54-
55-
```javascript
56-
import * as core from '@actions/core';
57-
...
58-
59-
async function run() {
60-
try {
61-
...
62-
}
63-
catch (error) {
64-
core.setFailed(error.message);
65-
}
66-
}
67-
68-
run()
69-
```
70-
71-
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
72-
73-
## Publish to a distribution branch
74-
75-
Actions are run from GitHub repos so we will checkin the packed dist folder.
76-
77-
Then run [ncc](https://github.com/zeit/ncc) and push the results:
78-
```bash
79-
$ npm run package
80-
$ git add dist
81-
$ git commit -a -m "prod dependencies"
82-
$ git push origin releases/v1
83-
```
84-
85-
Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project.
86-
87-
Your action is now published! :rocket:
88-
89-
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
90-
91-
## Validate
92-
93-
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))
94-
95-
```yaml
96-
uses: ./
97-
with:
98-
milliseconds: 1000
99-
```
49+
0. [wuba/Taro-Mortgage-Calculator](https://github.com/wuba/Taro-Mortgage-Calculator/tree/master/.github/workflows/main.yml)
10050
101-
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket:
51+
## Acknowledgements
10252
103-
## Usage:
53+
We use [jsDelivr](https://www.jsdelivr.com/?docs=gh) as the cdn service.
54+
## LICENSE
10455
105-
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action
56+
The MIT License (MIT)

__tests__/main.test.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
import {wait} from '../src/wait'
2-
import * as process from 'process'
3-
import * as cp from 'child_process'
4-
import * as path from 'path'
5-
import {expect, test} from '@jest/globals'
1+
import {test} from '@jest/globals'
62

7-
test('throws invalid number', async () => {
8-
const input = parseInt('foo', 10)
9-
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
10-
})
11-
12-
test('wait 500 ms', async () => {
13-
const start = new Date()
14-
await wait(500)
15-
const end = new Date()
16-
var delta = Math.abs(end.getTime() - start.getTime())
17-
expect(delta).toBeGreaterThan(450)
18-
})
19-
20-
// shows how the runner will run a javascript action with env / stdout protocol
21-
test('test runs', () => {
22-
process.env['INPUT_MILLISECONDS'] = '500'
23-
const np = process.execPath
24-
const ip = path.join(__dirname, '..', 'lib', 'main.js')
25-
const options: cp.ExecFileSyncOptions = {
26-
env: process.env
27-
}
28-
console.log(cp.execFileSync(np, [ip], options).toString())
29-
})
3+
test('test runs', () => {})

action.yml

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,82 @@
1-
name: 'Your name here'
2-
description: 'Provide a description here'
3-
author: 'Your name or organization here'
1+
name: 'Taro React Native Release'
2+
description: 'Taro React Native Release'
3+
author: 'Tony Chen'
4+
branding:
5+
icon: 'package'
6+
color: 'blue'
47
inputs:
5-
milliseconds: # change this
8+
token:
69
required: true
7-
description: 'input description here'
8-
default: 'default value if applicable'
10+
description: 'github token'
11+
refname:
12+
required: false
13+
description: 'ref name, tag or branch'
14+
cdnhost:
15+
required: false
16+
description: 'cdn host'
17+
default: 'https://cdn.jsdelivr.net'
18+
cdnpath:
19+
required: false
20+
description: 'cdn path'
21+
default: '/gh'
22+
iosbundleoutput:
23+
required: false
24+
description: 'ios bundle path'
25+
default: 'ios/main.js'
26+
iosqrpath:
27+
required: false
28+
description: 'ios qr path'
29+
default: 'release/qrcode/ios.png'
30+
iosassetsdest:
31+
required: false
32+
description: 'ios assets dest'
33+
default: 'ios/assets'
34+
iossourcemapoutput:
35+
required: false
36+
description: 'File name where to store the sourcemap file for resulting bundle'
37+
default: 'ios/main.map'
38+
iossourcemapuseabsolutepath:
39+
required: false
40+
description: 'Report SourceMapURL using its full path'
41+
default: ''
42+
iossourcemapsourcesroot:
43+
required: false
44+
description: 'Path to make sourcemaps sources entries relative to'
45+
default: ''
46+
androidbundleoutput:
47+
required: false
48+
description: 'android bundle path'
49+
default: 'android/main.js'
50+
androidqrpath:
51+
required: false
52+
description: 'android qr path'
53+
default: 'release/qrcode/android.png'
54+
androidassetsdest:
55+
required: false
56+
description: 'android assets dest'
57+
default: 'android/assets'
58+
androidsourcemapoutput:
59+
required: false
60+
description: 'File name where to store the sourcemap file for resulting bundle'
61+
default: 'android/main.map'
62+
androidsourcemapuseabsolutepath:
63+
required: false
64+
description: 'Report SourceMapURL using its full path'
65+
default: ''
66+
androidsourcemapsourcesroot:
67+
required: false
68+
description: 'Path to make sourcemaps sources entries relative to'
69+
default: ''
70+
appname:
71+
required: false
72+
description: 'app name'
73+
logo:
74+
required: false
75+
description: 'app logo'
76+
releaseprefix:
77+
required: false
78+
description: 'release markdown prefix'
79+
default: 'Use [Taro Playground App](https://github.com/wuba/taro-playground) to scan the following qr codes:'
980
runs:
1081
using: 'node12'
1182
main: 'dist/index.js'

0 commit comments

Comments
 (0)