Skip to content

Commit

Permalink
fix: release CI job (#131)
Browse files Browse the repository at this point in the history
This PR should fix the semantic release CI Job, but we also have to set
up the NPM_TOKEN secret in the repo to get it working.

We split some rules in the main Makefile to be able to compile only the
Go framework without other unnecessary stuff.

---------

Signed-off-by: D4ryl00 <[email protected]>
  • Loading branch information
D4ryl00 authored Apr 9, 2024
1 parent 6859901 commit c80efd4
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 22 deletions.
48 changes: 45 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,58 @@ name: Semantic Release
on:
push:
branches:
- master
- main
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false
jobs:
semantic-release:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
detached: true
limit-access-to-actor: true
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

- name: Setup asdf
uses: asdf-vm/actions/install@v3
uses: asdf-vm/actions/setup@v3

- name: Setup Go version
run: |
asdf plugin add golang
asdf install golang
echo "go_version=$(asdf current golang | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Setup Node version
run: |
asdf plugin add nodejs
asdf install nodejs
asdf global nodejs 18.16.0
echo "node_version=$(asdf current nodejs | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Cache go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-

- name: Cache node_modules
id: node_modules-cache
uses: actions/cache@v4
with:
path: ./expo/node_modules
key: ${{ runner.OS }}-node-${{ env.node_version }}-${{ hashFiles('expo/package-lock.json') }}
restore-keys: ${{ runner.OS }}-node-${{ env.node_version }}-

- name: Compile frameworks
working-directory: expo
Expand Down
3 changes: 3 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"branches": ["main"]
}
3 changes: 0 additions & 3 deletions .releaserc.js

This file was deleted.

10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ PATH := $(GO_BIND_BIN_DIR):$(PATH)
all build: generate build.ios build.android

# Build iOS framework
build.ios: generate $(gnocore_xcframework)
build.ios: generate framework.ios
ifeq ($(OS),Darwin)
@echo "generate iOS framework"
cd $(APP_OUTPUT_DIR); $(MAKE) node_modules
cd $(APP_OUTPUT_DIR); $(MAKE) ios/$(APP_NAME).xcworkspace TEMPLATE_PROJECT=$(APP_NAME)
endif

# Build Android aar & jar
build.android: generate $(gnocore_aar) $(gnocore_jar)
build.android: generate framework.android
cd $(APP_OUTPUT_DIR); $(MAKE) node_modules

# Generate API from protofiles
Expand Down Expand Up @@ -133,6 +133,9 @@ $(TEMPDIR)/.tool-versions: .tool-versions

# - Bind - ios framework

framework.ios: $(gnocore_xcframework)
.PHONY: framework.ios

$(gnocore_xcframework): $(bind_init_files) $(go_deps)
ifeq ($(OS),Darwin)
@mkdir -p $(dir $@)
Expand All @@ -147,6 +150,9 @@ _bind.clean.ios:

# - Bind - android aar and jar

framework.android: $(gnocore_aar) $(gnocore_jar)
.PHONY: framework.android

$(gnocore_aar): $(bind_init_files) $(go_deps)
@mkdir -p $(dir $@) .cache/bind/android
$(gomobile) bind -v \
Expand Down
15 changes: 13 additions & 2 deletions expo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ build.android: $(ANDROID_FRAMEWORK_DST)
.PHONY: build.android

$(ANDROID_FRAMEWORK_SRC):
cd $(PROJECT_DIR); $(MAKE) build.android
cd $(PROJECT_DIR); $(MAKE) framework.android

$(ANDROID_FRAMEWORK_DST): $(ANDROID_FRAMEWORK_SRC)
mkdir -p $(ANDROID_FRAMEWORK_OUTPUT_DIR)
Expand All @@ -40,7 +40,7 @@ build.ios: $(IOS_FRAMEWORK_DST)
.PHONY: build.ios

$(IOS_FRAMEWORK_SRC):
cd $(PROJECT_DIR); $(MAKE) build.ios
cd $(PROJECT_DIR); $(MAKE) framework.ios

$(IOS_FRAMEWORK_DST): $(IOS_FRAMEWORK_SRC)
mkdir -p $(IOS_FRAMEWORK_OUTPUT_DIR)
Expand All @@ -49,3 +49,14 @@ $(IOS_FRAMEWORK_DST): $(IOS_FRAMEWORK_SRC)
clean.ios:
rm -fr $(IOS_FRAMEWORK_OUTPUT_DIR)
.PHONY: clean.ios

######### NPM #########
npm.pack: build
npm install
npm pack
.PHONY: npm.pack

npm.publish: build
npm install
npm publish
.PHONY: npm.publish
18 changes: 16 additions & 2 deletions expo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cd my-app
## Add the package to your npm dependencies

```
npm install @berty/gnonative
npm install @gnolang/gnonative
```

## Customize the app
Expand All @@ -46,7 +46,7 @@ Open App.js and replace the content with this:
import React, { useEffect, useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';

import * as Gnonative from '@berty/gnonative';
import * as Gnonative from '@gnolang/gnonative';

export default function App() {
const gno = Gnonative.useGno();
Expand Down Expand Up @@ -102,3 +102,17 @@ npx expo run:ios
For bare React Native projects, you must ensure that you have
[installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/)
before continuing.

# Generate new NPM package

You can run one of the following command:

```shell
make pack
```

or

```shell
make publish
```
2 changes: 1 addition & 1 deletion expo/example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Gnonative from '@berty/gnonative';
import * as Gnonative from '@gnolang/gnonative';
import React, { useEffect, useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';

Expand Down
2 changes: 1 addition & 1 deletion expo/example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ config.resolver.nodeModulesPaths = [
];

config.resolver.extraNodeModules = {
'@berty/gnonative': '..',
'@gnolang/gnonative': '..',
};

config.watchFolders = [path.resolve(__dirname, '..')];
Expand Down
4 changes: 2 additions & 2 deletions expo/example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"compilerOptions": {
"strict": true,
"paths": {
"@berty/gnonative": [
"@gnolang/gnonative": [
"../src/index"
],
"@berty/gnonative/*": [
"@gnolang/gnonative/*": [
"../src/*"
]
}
Expand Down
2 changes: 1 addition & 1 deletion expo/example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = async (env, argv) => {
{
...env,
babel: {
dangerouslyAddModulePathsToTranspile: ['@bertygnonative'],
dangerouslyAddModulePathsToTranspile: ['@gnolang/gnonative'],
},
},
argv,
Expand Down
8 changes: 4 additions & 4 deletions expo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion expo/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@berty/gnonative",
"name": "@gnolang/gnonative",
"version": "0.1.2",
"description": "Develop for Gno using your app's native language ",
"main": "build/index.js",
Expand Down

0 comments on commit c80efd4

Please sign in to comment.