Skip to content

Commit

Permalink
chore: release setup
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra committed Jul 2, 2024
1 parent a929826 commit 658365f
Show file tree
Hide file tree
Showing 19 changed files with 308 additions and 136 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Pipeline

on:
push:
branches:
- main

pull_request:

workflow_dispatch:
inputs:
release-type:
description: "Type of release (major, minor, patch, alpha)"
required: true
default: alpha
type: choice
options:
- major
- minor
- patch
- alpha

jobs:
continuous-integration:
name: "Continuous Integration"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- name: Install dependencies
run: pnpm install

- name: Style
run: pnpm style:check

- name: Build
run: pnpm build

- name: Check types
run: pnpm types:check

continuous-deployment:
if: github.event_name == 'workflow_dispatch'

name: 'Continuous Deployment'
runs-on: ubuntu-latest
needs: ['continuous-integration']

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build

- name: Set git configuration
run: |
git config user.name "Animo Solutions"
git config user.email "[email protected]"
- name: Publish
id: publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
if [ ${{ inputs.release-type }} == 'alpha' ]; then
pnpm release --preRelease=alpha
else
pnpm release -i=${{ inputs.release-type }}
fi
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ __tests__
/android/build/
/ausweis-example/

./src
src
plugin/src
tsconfig.json
16 changes: 16 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"github": {
"release": true
},
"npm": {
"skipChecks": true,
"tag": "latest"
},
"git": {
"push": false,
"commit": false,
"requireCommits": true,
"tagAnnotation": "${version}",
"requireBranch": "main"
}
}
11 changes: 0 additions & 11 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion app.plugin.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./plugin/build');
module.exports = require('./plugin/build')
5 changes: 1 addition & 4 deletions ausweis-example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"orientation": "portrait",
"scheme": "ausweis-example",
"userInterfaceStyle": "automatic",
"plugins": [
"expo-router",
"../app.plugin.js"
],
"plugins": ["expo-router", "../app.plugin.js"],
"experiments": {
"typedRoutes": true
},
Expand Down
17 changes: 6 additions & 11 deletions ausweis-example/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { View, Text, StyleSheet } from "react-native";
import { StyleSheet, Text, View } from 'react-native'

export default function App() {
return (
<View
style={[
StyleSheet.absoluteFill,
{ flex: 1, alignContent: "center", justifyContent: "center" },
]}
>
<Text>Hello</Text>
</View>
);
return (
<View style={[StyleSheet.absoluteFill, { flex: 1, alignContent: 'center', justifyContent: 'center' }]}>
<Text>Hello</Text>
</View>
)
}
10 changes: 5 additions & 5 deletions ausweis-example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = (api) => {
api.cache(true);
return {
presets: ["babel-preset-expo"],
};
};
api.cache(true)
return {
presets: ['babel-preset-expo'],
}
}
11 changes: 2 additions & 9 deletions ausweis-example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@
"compilerOptions": {
"strict": true,
"paths": {
"@/*": [
"./*"
]
"@/*": ["./*"]
}
},
"include": [
"**/*.ts",
"**/*.tsx",
".expo/types/**/*.ts",
"expo-env.d.ts"
]
"include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"]
}
35 changes: 35 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
"formatter": {
"lineWidth": 120,
"indentStyle": "space"
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
},
"formatter": {
"semicolons": "asNeeded",
"quoteStyle": "single",
"trailingCommas": "es5",
"lineWidth": 120,
"indentStyle": "space"
}
},
"json": {
"parser": {
"allowComments": true
}
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true
},
"vcs": {
"useIgnoreFile": true,
"clientKind": "git",
"enabled": true
}
}
18 changes: 7 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"scripts": {
"build": "expo-module build",
"clean": "expo-module clean",
"prepublishOnly": "expo-module prepublishOnly",
"build": "EXPO_NONINTERACTIVE=1 expo-module build && EXPO_NONINTERACTIVE=1 expo-module build plugin",
"style:check": "biome check --unsafe",
"style:fix": "biome check --write --unsafe",
"types:check": "EXPO_NONINTERACTIVE=1 expo-module typecheck && EXPO_NONINTERACTIVE=1 expo-module plugin typecheck",
"expo-module": "expo-module",
"open:ios": "xed example/ios",
"open:android": "open -a \"Android Studio\" example/android"
},
"keywords": [
"react-native",
"expo",
"ausweis-sdk",
"AusweisSdk"
],
"keywords": ["react-native", "expo", "ausweis-sdk", "AusweisSdk"],
"repository": "https://github.com/animo/expo-ausweis-sdk",
"bugs": {
"url": "https://github.com/animo/expo-ausweis-sdk/issues"
Expand All @@ -26,10 +22,10 @@
"license": "Apache-2.0",
"homepage": "https://github.com/animo/expo-ausweis-sdk#readme",
"dependencies": {
"@expo/config-plugins": "^8.0.6",
"resolve-from": "^5.0.0"
"@expo/config-plugins": "^8.0.6"
},
"devDependencies": {
"@biomejs/biome": "1.8.1",
"@types/node": "^20.14.9",
"@types/react": "^18.0.25",
"@types/resolve-from": "^5.0.1",
Expand Down
19 changes: 6 additions & 13 deletions plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import {
createRunOncePlugin,
type ConfigPlugin,
withPlugins,
} from "@expo/config-plugins";
import { type ConfigPlugin, createRunOncePlugin, withPlugins } from '@expo/config-plugins'

import { withAndroidAusweisSdk } from "./withAndroidAusweisSdk";
import { withIosAusweisSdk } from "./withIosAusweisSdk";
import { withAndroidAusweisSdk } from './withAndroidAusweisSdk'
import { withIosAusweisSdk } from './withIosAusweisSdk'

const withAusweisSdk: ConfigPlugin = (config) => {
return withPlugins(config, [withAndroidAusweisSdk, withIosAusweisSdk]);
};
return withPlugins(config, [withAndroidAusweisSdk, withIosAusweisSdk])
}

export default createRunOncePlugin(
withAusweisSdk,
"@animo-id/expo-ausweis-sdk",
);
export default createRunOncePlugin(withAusweisSdk, '@animo-id/expo-ausweis-sdk')
4 changes: 2 additions & 2 deletions plugin/src/withAndroidAusweisSdk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type ConfigPlugin, withAndroidManifest, withDangerousMod, withMainApplication } from '@expo/config-plugins'
import path from 'node:path'
import fs from 'node:fs'
import path from 'node:path'
import { type ConfigPlugin, withAndroidManifest, withDangerousMod, withMainApplication } from '@expo/config-plugins'
import { addAndroidImports } from './util'

/**
Expand Down
78 changes: 36 additions & 42 deletions plugin/src/withIosAusweisSdk.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
import type { ConfigPlugin } from "@expo/config-plugins";
import type { ConfigPlugin } from '@expo/config-plugins'

import path from "node:path";
import fs from "node:fs/promises";
import { withDangerousMod } from "@expo/config-plugins";
import {
mergeContents,
MergeResults,
} from "@expo/config-plugins/build/utils/generateCode";
import fs from 'node:fs/promises'
import path from 'node:path'
import { withDangerousMod } from '@expo/config-plugins'
import { type MergeResults, mergeContents } from '@expo/config-plugins/build/utils/generateCode'

const podSource = `pod 'AusweisApp2', :path => File.join(File.dirname(\`node --print "require.resolve('@animo-id/expo-ausweis-sdk/package.json')"\`), "ios/Specs")`;
const podSource = `pod 'AusweisApp2', :path => File.join(File.dirname(\`node --print "require.resolve('@animo-id/expo-ausweis-sdk/package.json')"\`), "ios/Specs")`

export function addAusweisApp2Pod(src: string): MergeResults {
return mergeContents({
tag: "@animo-id/expo-ausweis-sdk",
src,
newSrc: podSource,
anchor: /use_native_modules/,
offset: 0,
comment: "#",
});
return mergeContents({
tag: '@animo-id/expo-ausweis-sdk',
src,
newSrc: podSource,
anchor: /use_native_modules/,
offset: 0,
comment: '#',
})
}

const withIosAusweisApp2Pod: ConfigPlugin = (config) => {
return withDangerousMod(config, [
"ios",
async (config) => {
const filePath = path.join(
config.modRequest.platformProjectRoot,
"Podfile",
);
const contents = await fs.readFile(filePath, "utf-8");
const results = addAusweisApp2Pod(contents);

if (!results.didMerge) {
console.log(
"ERROR: Cannot add AusweisApp2 to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.",
);
return config;
}

await fs.writeFile(filePath, results.contents);
return config;
},
]);
};
return withDangerousMod(config, [
'ios',
async (config) => {
const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile')
const contents = await fs.readFile(filePath, 'utf-8')
const results = addAusweisApp2Pod(contents)

if (!results.didMerge) {
console.log(
"ERROR: Cannot add AusweisApp2 to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile."
)
return config
}

await fs.writeFile(filePath, results.contents)
return config
},
])
}

const withIosAusweisSdk: ConfigPlugin = (config) => {
return withIosAusweisApp2Pod(config);
};
return withIosAusweisApp2Pod(config)
}

export { withIosAusweisSdk };
export { withIosAusweisSdk }
2 changes: 1 addition & 1 deletion plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
},
"include": ["./src"],
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
}
}
Loading

0 comments on commit 658365f

Please sign in to comment.