|
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> |
| 1 | +# Get Release Info |
4 | 2 |
|
5 | | -# Create a JavaScript Action using TypeScript |
| 3 | +[](https://github.com/kaliber5/action-get-release/actions/workflows/test.yml) |
6 | 4 |
|
7 | | -Use this template to bootstrap the creation of a TypeScript action.:rocket: |
| 5 | +Github action to fetch release data. Supports querying by |
8 | 6 |
|
9 | | -This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance. |
| 7 | +- release ID |
| 8 | +- latest release |
| 9 | +- tag name |
| 10 | +- tag name for draft releases |
10 | 11 |
|
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 |
24 | | -``` |
25 | | - |
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 contains defines the inputs and output for your action. |
46 | | - |
47 | | -Update the action.yml with your name, description, inputs and outputs for your action. |
48 | | - |
49 | | -See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions) |
50 | | - |
51 | | -## Change the Code |
52 | | - |
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)) |
| 12 | +## Usage |
94 | 13 |
|
95 | 14 | ```yaml |
96 | | -uses: ./ |
97 | | -with: |
98 | | - milliseconds: 1000 |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Get latest release |
| 20 | + id: latest_release |
| 21 | + uses: kaliber5/action-get-release@v1 |
| 22 | + with: |
| 23 | + token: ${{ github.token }} |
| 24 | + latest: true |
99 | 25 | ``` |
100 | 26 |
|
101 | | -See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket: |
102 | | -
|
103 | | -## Usage: |
104 | | -
|
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 |
| 27 | +### Inputs |
| 28 | +
|
| 29 | +- `token`: The Github token used for authentication. Required, `${{ github.token }}` can be used usually. |
| 30 | +- `owner`: Name of the owner of the repo, taken from current repo by default. |
| 31 | +- `repo`: Name of the repository, taken from current repo by default. |
| 32 | +- `id`: The ID to identify the release. |
| 33 | +- `tag_name`: Tag name to identify the release. |
| 34 | +- `latest`: Will fetch the latest release if set to true. |
| 35 | +- `draft`: Set to true if you are looking for an unpublished draft release. In this case `tag_name` must also be set. |
| 36 | + |
| 37 | +One of `id`, `tag_name` or `latest` inputs must be provided |
| 38 | + |
| 39 | +### Outputs |
| 40 | + |
| 41 | +- `id`: The ID of the Release |
| 42 | +- `url`: The release url |
| 43 | +- `html_url`: The url users can navigate to in order to view the release |
| 44 | +- `assets_url`: The release assets url |
| 45 | +- `upload_url`: The url for uploading assets to the release |
| 46 | +- `name`: The release name |
| 47 | +- `tag_name`: The git tag associated with the release |
| 48 | +- `draft`: Is draft |
| 49 | +- `prerelease`: Is pre-release |
| 50 | +- `target_commitish`: The release was create to which target branch |
| 51 | +- `created_at`: Created date |
| 52 | +- `published_at`: Published date |
0 commit comments