Skip to content

Commit 0344ac7

Browse files
authored
Merge pull request #57 from talsec/add_auto_release
feat(github): add ci for auto releases
2 parents 88d2598 + ac9684a commit 0344ac7

File tree

7 files changed

+12156
-5
lines changed

7 files changed

+12156
-5
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Publish new release
2+
on:
3+
pull_request:
4+
types: [closed]
5+
branches:
6+
- 'master'
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
jobs:
12+
release_gh:
13+
name: Create new GitHub release
14+
if: contains(github.event.pull_request.labels.*.name, 'release')
15+
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20.x'
24+
registry-url: 'https://registry.npmjs.org'
25+
26+
- name: git config
27+
run: |
28+
git config user.name "${GITHUB_ACTOR}"
29+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
30+
31+
- name: Generate Changelog
32+
run: node ./scripts/extract_changelog.js > ${{ github.workspace }}-CURRENT_CHANGELOG.md
33+
34+
- name: Get latest version
35+
run: echo "PACKAGE_VERSION=$(node scripts/extract_version.js)" >> $GITHUB_ENV
36+
37+
- name: GitHub Release
38+
uses: softprops/action-gh-release@v2
39+
with:
40+
name: freeRASP ${{ env.PACKAGE_VERSION }}
41+
tag_name: v${{ env.PACKAGE_VERSION }}
42+
body_path: ${{ github.workspace }}-CURRENT_CHANGELOG.md
43+
44+
publish_npmjs:
45+
name: Publish release to npm.js
46+
needs: release_gh
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Setup Node
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: '20.x'
55+
registry-url: 'https://registry.npmjs.org'
56+
node-version-file: .nvmrc
57+
58+
- name: Cache dependencies
59+
id: yarn-cache
60+
uses: actions/cache@v4
61+
with:
62+
path: |
63+
**/node_modules
64+
.yarn/install-state.gz
65+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
66+
restore-keys: |
67+
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
68+
${{ runner.os }}-yarn-
69+
70+
- name: Install dependencies
71+
if: steps.yarn-cache.outputs.cache-hit != 'true'
72+
run: yarn install --immutable
73+
shell: bash
74+
75+
- name: Build Expo plugin
76+
working-directory: ./plugin
77+
run: tsc
78+
shell: bash
79+
80+
- name: Configure git
81+
run: |
82+
git config user.name "${GITHUB_ACTOR}"
83+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
84+
85+
- name: Publish package
86+
run: npm publish
87+
env:
88+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
yarn.lock
2-
31
# OSX
42
#
53
.DS_Store

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ config.json
22
config.example.json
33
*.zip
44
*.tgz
5-
5+
scripts/
66
plugin/src
77

88
# OSX

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"bootstrap": "yarn example && yarn install && yarn example pods",
1717
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build",
1818
"build:plugin": "tsc --build plugin"
19-
2019
},
2120
"keywords": [
2221
"react-native",
@@ -80,7 +79,6 @@
8079
"engines": {
8180
"node": ">= 16.0.0"
8281
},
83-
"packageManager": "^[email protected]",
8482
"jest": {
8583
"preset": "react-native",
8684
"modulePathIgnorePatterns": [

scripts/extract_changelog.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const fs = require('fs');
2+
3+
const filePath = './CHANGELOG.md';
4+
5+
const fileContent = fs.readFileSync(filePath, 'utf-8');
6+
7+
const trimmedContent = fileContent
8+
.replace(/\s*#\s*freeRASP.*/, '') // trim the latest version header
9+
.replace(/\s*#\s*freeRASP([\s\S])*/, '') // trim everything after the latest changelog data
10+
.trim(); // trim leading and trailing whitespaces
11+
12+
console.log(trimmedContent);

scripts/extract_version.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { version } = require('../package.json');
2+
console.log(version);

0 commit comments

Comments
 (0)