Skip to content

Commit ccf697b

Browse files
committed
first commit
0 parents  commit ccf697b

File tree

17 files changed

+70033
-0
lines changed

17 files changed

+70033
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: 'Draft release'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_strategy:
7+
description: 'Version strategy: The strategy to used to update the version based on semantic versioning (more info at https://semver.org/).'
8+
required: true
9+
default: 'patch'
10+
type: 'choice'
11+
options:
12+
- 'major'
13+
- 'minor'
14+
- 'patch'
15+
secrets:
16+
ACTIONS_BOT_TOKEN:
17+
required: true
18+
workflow_call:
19+
inputs:
20+
version_strategy:
21+
description: 'Version strategy: The strategy to used to update the version based on semantic versioning (more info at https://semver.org/).'
22+
required: true
23+
type: 'string'
24+
secrets:
25+
ACTIONS_BOT_TOKEN:
26+
required: true
27+
28+
jobs:
29+
draft-release:
30+
name: 'Draft Release'
31+
runs-on: 'ubuntu-latest'
32+
steps:
33+
- name: 'Checkout'
34+
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
35+
36+
- name: 'Setup node'
37+
uses: 'actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a' # ratchet:actions/setup-node@v4
38+
with:
39+
node-version: '22.x'
40+
41+
- name: 'Build'
42+
id: 'build'
43+
shell: 'bash'
44+
env:
45+
VERSION_STRATEGY: '${{ inputs.version_strategy }}'
46+
run: |-
47+
CURRENT_VERSION="$(jq -r .version ./package.json)"
48+
echo "::debug::computed current version: ${CURRENT_VERSION}"
49+
echo "current_version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
50+
51+
npm version "${VERSION_STRATEGY}" \
52+
--no-git-tag-version \
53+
--no-commit-hooks \
54+
--no-workspaces-update
55+
NEXT_VERSION="$(jq -r .version ./package.json)"
56+
echo "::debug::computed next version: ${NEXT_VERSION}"
57+
echo "next_version=${NEXT_VERSION}" >> $GITHUB_OUTPUT
58+
59+
npm ci
60+
[[ "$(npm run --json | jq -r 'has("docs")')" == "true" ]] && npm run docs
61+
npm run build
62+
63+
- name: 'Generate release notes'
64+
id: 'generate-release-notes'
65+
uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' # ratchet:actions/github-script@v7
66+
env:
67+
CURRENT_VERSION: '${{ steps.build.outputs.current_version }}'
68+
NEXT_VERSION: '${{ steps.build.outputs.next_version }}'
69+
with:
70+
github-token: '${{ secrets.ACTIONS_BOT_TOKEN }}'
71+
script: |-
72+
let releaseNotes = '';
73+
try {
74+
const releaseNotesResponse = await github.rest.repos.generateReleaseNotes({
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
tag_name: `v${process.env.NEXT_VERSION}`,
78+
previous_tag_name: `v${process.env.CURRENT_VERSION}`,
79+
});
80+
releaseNotes = releaseNotesResponse.data.body;
81+
} catch(err) {
82+
core.debug(`error generating release notes: ${err}`)
83+
core.warning('No existing releases found, assuming initial release');
84+
releaseNotes = 'Initial release'
85+
}
86+
core.setOutput('release_notes', releaseNotes)
87+
88+
- name: 'Create/Update Pull Request'
89+
uses: 'abcxyz/pkg/.github/actions/create-pull-request@main' # ratchet:exclude
90+
with:
91+
token: '${{ secrets.ACTIONS_BOT_TOKEN }}'
92+
base_branch: '${{ github.ref_name }}'
93+
head_branch: 'actions/draft-release-${{ github.ref_name }}'
94+
title: 'Release: v${{ steps.build.outputs.next_version }}'
95+
body: '${{ steps.generate-release-notes.outputs.release_notes }}'
96+
compute_paths: true

.github/workflows/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on:
2+
workflow_dispatch:
3+
4+
jobs:
5+
job_id:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout
9+
uses: actions/checkout@v4
10+
- name: Tools cache
11+
id: tool-caches
12+
uses: actions/cache@v4
13+
with:
14+
path: /opt/hostedtoolcache/srcpush
15+
key: srcpush-${{ runner.os }}-${{ github.run_id }}
16+
restore-keys: |
17+
srcpush-${{ runner.os }}-
18+
- name: Setup Source Push CLI
19+
uses: 'srcpush/srcpush-github-action@v1.0.0'
20+
id: setup-srcpush-cli
21+
with:
22+
version: 'latest'
23+
accessKey: ${{ secrets.SRCPUSH_ACCESS_KEY }}
24+
- name: Release Android bundle
25+
run: srcpush release-react myAmazingAndroidApp android -d Staging
26+
- name: Release ios bundle
27+
run: srcpush release-react myAmazingIOSApp ios -d Staging

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: 'Release'
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'release/**/*'
8+
9+
jobs:
10+
create-release:
11+
if: "startsWith(github.event.head_commit.message, 'Release: v')"
12+
runs-on: 'ubuntu-latest'
13+
outputs:
14+
created: '${{ steps.create-release.outputs.created || false }}'
15+
tag: '${{ steps.create-release.outputs.tag }}'
16+
version: '${{ steps.create-release.outputs.version }}'
17+
steps:
18+
- name: 'Create release'
19+
id: 'create-release'
20+
uses: 'abcxyz/pkg/.github/actions/create-release@main' # ratchet:exclude
21+
with:
22+
github_token: '${{ secrets.ACTIONS_BOT_TOKEN }}'
23+
expected_email: 'support@srcpush.com'
24+
25+
publish-release:
26+
runs-on: 'ubuntu-latest'
27+
needs:
28+
- 'create-release'
29+
steps:
30+
- name: 'Publish release'
31+
env:
32+
GH_TOKEN: '${{ secrets.ACTIONS_BOT_TOKEN }}'
33+
RELEASE_VERSION: 'v${{ needs.create-release.outputs.version }}'
34+
REPO: '${{ github.repository }}'
35+
run: |-
36+
gh release edit "${RELEASE_VERSION}" \
37+
--repo "${REPO}" \
38+
--draft=false
39+
40+
cleanup-failed-release:
41+
if: |-
42+
${{ always() && needs.create-release.outputs.created == 'true' && contains(fromJSON('["failure", "cancelled", "skipped"]'), needs.publish-release.result) }}
43+
runs-on: 'ubuntu-latest'
44+
needs:
45+
- 'create-release'
46+
- 'publish-release'
47+
steps:
48+
- name: 'Cleanup failed release'
49+
env:
50+
GH_TOKEN: '${{ secrets.ACTIONS_BOT_TOKEN }}'
51+
RELEASE_VERSION: 'v${{ needs.create-release.outputs.version }}'
52+
REPO: '${{ github.repository }}'
53+
run: |-
54+
gh release delete "${RELEASE_VERSION}" \
55+
--repo "${REPO}" \
56+
--yes

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
bin
2+
dist
3+
node_modules
4+
.idea
5+
.env
6+
.azure
7+
historyfix.sh

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# `srcpush-github-action` GitHub Action
2+
3+
Configures the Source Push Command Line Interface in the GitHub Actions environment.
4+
5+
## Prerequisites
6+
7+
- This action runs using Node 20. If you are using self-hosted GitHub Actions
8+
runners, you must use a [runner version](https://github.com/actions/virtual-environments) that supports this
9+
version or newer.
10+
11+
## Usage
12+
13+
GitHub action supports all the commands available in the Source Push CLI of appropriate version.
14+
Please keep in mind that some commands (such as `release-react`) need to be executed and make sense only after you have
15+
loaded all the dependencies of your project and build React Native app.
16+
17+
```yaml
18+
jobs:
19+
job_id:
20+
# Any runner supporting Node 20 or newer
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Setup Source Push CLI
24+
uses: 'srcpush/srcpush-github-action@v1'
25+
id: setup-srcpush-cli
26+
with:
27+
version: 'latest'
28+
accessKey: ${{ secrets.SRCPUSH_ACCESS_KEY }}
29+
- name: Release Android bundle
30+
run: srcpush release-react myAmazingAndroidApp android -d Staging
31+
- name: Release ios bundle
32+
run: srcpush release-react myAmazingIOSApp ios -d Staging
33+
```
34+
35+
## Inputs
36+
37+
- `version`(Optional, default: `latest`).
38+
A string representing the version or version constraint of the Source Push CLI
39+
(`srcpush`) to install (e.g. `"0.0.3"` or `">= 0.0.2"`). The default
40+
value is `"latest"`, which will always download and install the latest
41+
available CLI version.
42+
43+
- uses: 'srcpush/srcpush-github-action@v1'
44+
with:
45+
version: '>= 0.0.3'
46+
47+
If there is no installed `srcpush` version that matches the given
48+
constraint, this GitHub Action will download and install the latest
49+
available version that still matches the constraint.
50+
51+
You are responsible for ensuring the `srcpush` version matches the features required.
52+
53+
- `accessKey`(Optional). Source Push access key created in the [app](http://console.srcpush.com/). Considered to be a secret.
54+
55+
- uses: 'srcpush/srcpush-github-action@v1'
56+
with:
57+
accessKey: ${{ secrets.SRCPUSH_ACCESS_KEY }}
58+
59+
You are responsible for ensuring the accessKey was not neither expired nor deleted.
60+
61+
If no accessKey given you must authenticate CLI before executing any commands require authentication
62+
63+
- name: Authenticate Source Push CLI
64+
run: srcpush login --accessKey ${{ secrets.SRCPUSH_ACCESS_KEY }}
65+
66+
## Outputs
67+
68+
- `version`: Version of Source Push CLI that was installed.
69+
70+
## Caching
71+
72+
Under the hood action uses [@actions/tool-cache](https://www.npmjs.com/package/@actions/tool-cache) npm package to
73+
cache installed tooling (`/opt/hostedtoolcache/srcpush`) to speed up further workflow executions.
74+
It works out the box for self-hosted runners where for GitHub-hosted runners the following config is needed to persist
75+
changes made by action:
76+
77+
```yaml
78+
- name: Tools cache
79+
id: tool-caches
80+
uses: actions/cache@v4
81+
with:
82+
path: /opt/hostedtoolcache/srcpush
83+
key: srcpush-${{ runner.os }}-${{ github.run_id }}
84+
restore-keys: |
85+
srcpush-${{ runner.os }}-
86+
```
87+
88+
## Versioning
89+
90+
We recommend pinning to the latest available major version:
91+
92+
```yaml
93+
- uses: 'srcpush/srcpush-github-action@v1'
94+
```
95+
96+
While this action attempts to follow semantic versioning, human errors can occur.
97+
To avoid accidental breaking changes, you can pin to a specific version:
98+
99+
```yaml
100+
- uses: 'srcpush/srcpush-github-action@v1.0.0'
101+
```
102+
103+
However, you will not get automatic security updates or new features without
104+
explicitly updating your version number.
105+
106+
## Questions, Issues and Support
107+
108+
If you have any questions or issues with this action, please [open an issue](https://github.com/srcpush/srcpush-github-action/issues)
109+
on this repository or send email to [support@srcpush.com](mailto:support@srcpush.com).

action.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Set up Source Push management cli environment
3+
author: Source Push
4+
description: |-
5+
Downloads, installs, and configures a Source Push management CLI environment.
6+
Adds the `srcpush` CLI command to the $PATH.
7+
runs:
8+
using: node20
9+
main: build/setup/index.js
10+
post: build/setup-post/index.js
11+
inputs:
12+
version:
13+
description: |-
14+
A string representing the version or version constraint of the Source Push CLI
15+
(`srcpush`) to install (e.g. `"0.0.3"` or `">= 0.0.3"`). The default
16+
value is `"latest"`, which will always download and install the latest
17+
available SRCPush CLI version.
18+
19+
- uses: 'srcpush/srcpush-github-action@v1'
20+
with:
21+
version: '>= 0.0.3'
22+
23+
If there is no installed `srcpush` version that matches the given constraint, this GitHub Action will download and
24+
install the latest available version that still matches the constraint.
25+
26+
You are responsible for ensuring the `srcpush` version matches the features required.
27+
default: "latest"
28+
required: false
29+
accessKey:
30+
description: |-
31+
Source Push access key. Considered to be a secret.
32+
33+
- uses: 'srcpush/srcpush-github-action@v1'
34+
with:
35+
accessKey: <your Source Push access-key from GitHub secrets>
36+
37+
You are responsible for ensuring the accessKey was not neither expired nor deleted by a user who created it.
38+
required: false
39+
outputs:
40+
version:
41+
description: |-
42+
Version of srcpush cli that was installed.
43+
44+
branding:
45+
icon: "terminal"
46+
color: "blue"

0 commit comments

Comments
 (0)