Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/actions/find-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,26 @@ inputs:
outputs:
artifact-id:
description: 'The ID of the artifact'
value: ${{ steps.find-artifact.outputs.artifact-id }}
artifact-url:
description: 'The URL of the artifact'
value: ${{ steps.find-artifact.outputs.artifact-url }}
artifact-ids:
description: 'All IDs of the artifacts matching the name'
value: ${{ steps.find-artifact.outputs.artifact-ids }}
runs:
using: 'node20'
main: 'index.js'
using: 'composite'
steps:
- name: Install dependencies
run: npm install
shell: bash
working-directory: ${{ github.action_path }}
- name: Find artifact
id: find-artifact
env:
INPUT_NAME: ${{ inputs.name }}
INPUT_RE_SIGN: ${{ inputs.re-sign }}
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
INPUT_REPOSITORY: ${{ inputs.repository }}
run: node ${{ github.action_path }}/index.mjs
shell: bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const core = require('@actions/core');
const github = require('@actions/github');
import * as core from "@actions/core";
import * as github from "@actions/github";

const perPage = 100; // Maximum allowed by GitHub API

Expand All @@ -9,8 +9,8 @@ async function fetchArtifacts(octokit, repository, name) {

while (true) {
const response = await octokit.rest.actions.listArtifactsForRepo({
owner: repository.split('/')[0],
repo: repository.split('/')[1],
owner: repository.split("/")[0],
repo: repository.split("/")[1],
name,
per_page: perPage,
page,
Expand All @@ -31,18 +31,31 @@ async function fetchArtifacts(octokit, repository, name) {
}

function getPrNumber() {
if (github.context.eventName === 'pull_request') {
if (github.context.eventName === "pull_request") {
return github.context.payload.pull_request.number;
}
return undefined;
}

async function run() {
try {
const token = core.getInput('github-token');
const repository = core.getInput('repository');
const name = core.getInput('name');
const reSign = core.getInput('re-sign');
const token = core.getInput("github_token") || process.env.GITHUB_TOKEN;

if (!token) {
throw new Error("GitHub token is required");
}

const repository = core.getInput("repository");
if (!repository) {
throw new Error("Repository is required");
}

const name = core.getInput("name");
if (!name) {
throw new Error("Artifact name is required");
}

const reSign = core.getInput("re_sign");
const prNumber = getPrNumber();

const octokit = github.getOctokit(token);
Expand All @@ -61,20 +74,20 @@ async function run() {
for (const artifact of artifacts) {
console.log(
`- ID: ${artifact.id}, Name: ${artifact.name}, Size: ${formatSize(
artifact.size_in_bytes,
)}, Expires at: ${artifact.expires_at}`,
artifact.size_in_bytes
)}, Expires at: ${artifact.expires_at}`
);
}

const firstArtifact = artifacts.find(artifact => !artifact.expired);
const firstArtifact = artifacts.find((artifact) => !artifact.expired);
console.log(`First artifact: ${JSON.stringify(firstArtifact, null, 2)}`);

const url = formatDownloadUrl(
repository,
firstArtifact.workflow_run.id,
firstArtifact.id,
firstArtifact.id
);
console.log('Stable download URL:', url);
console.log("Stable download URL:", url);

let artifactName = name;
// There are artifacts from PR but the base artifact is gone, recreate with the original name
Expand All @@ -84,12 +97,12 @@ async function run() {
} else if (prNumber && reSign) {
artifactName = `${name}-${prNumber}`;
}
core.setOutput('artifact-name', artifactName);
core.setOutput('artifact-id', firstArtifact.id);
core.setOutput('artifact-url', url);
core.setOutput("artifact-name", artifactName);
core.setOutput("artifact-id", firstArtifact.id);
core.setOutput("artifact-url", url);
core.setOutput(
'artifact-ids',
artifactsByPrNumber.map(artifact => artifact.id).join(' '),
"artifact-ids",
artifactsByPrNumber.map((artifact) => artifact.id).join(" ")
);
} catch (error) {
core.setFailed(`Action failed with error: ${error.message}`);
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/find-artifact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.0"
}
}
}
16 changes: 14 additions & 2 deletions .github/actions/rnef-native-fingerprint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ inputs:
outputs:
hash:
description: 'The fingerprint hash'
value: ${{ steps.fingerprint.outputs.hash }}
runs:
using: 'node20'
main: 'index.mjs'
using: 'composite'
steps:
- name: Install dependencies
run: npm install
shell: bash
working-directory: ${{ github.action_path }}
- name: Run fingerprint
id: fingerprint
env:
INPUT_PLATFORM: ${{ inputs.platform }}
INPUT_WORKING_DIRECTORY: ${{ inputs.working-directory }}
run: node ${{ github.action_path }}/index.mjs
shell: bash
20 changes: 10 additions & 10 deletions .github/actions/rnef-native-fingerprint/index.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import path from 'node:path';
import core from '@actions/core';
import {getConfig} from '@rnef/config';
import {nativeFingerprint} from '@rnef/tools';
import path from "node:path";
import core from "@actions/core";
import { getConfig } from "@rnef/config";
import { nativeFingerprint } from "@rnef/tools";

const ALLOWED_PLATFORMS = ['android', 'ios'];
const ALLOWED_PLATFORMS = ["android", "ios"];

async function run() {
const platform = core.getInput('platform');
const workingDirectory = core.getInput('working-directory');
const platform = core.getInput("platform");
const workingDirectory = core.getInput("working-directory");
if (!ALLOWED_PLATFORMS.includes(platform)) {
throw new Error(`Invalid platform: ${platform}`);
}
Expand All @@ -22,10 +22,10 @@ async function run() {
...fingerprintOptions,
});

console.log('Hash:', fingerprint.hash);
console.log('Sources:', fingerprint.sources);
console.log("Hash:", fingerprint.hash);
console.log("Sources:", fingerprint.sources);

core.setOutput('hash', fingerprint.hash);
core.setOutput("hash", fingerprint.hash);
}

await run();
5 changes: 3 additions & 2 deletions .github/actions/rnef-native-fingerprint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"name": "rnef-native-fingerprint",
"version": "1.0.0",
"description": "Generate native fingerprint for RNEF builds",
"main": "index.js",
"main": "index.mjs",
"dependencies": {
"@rnef/config": "^0.4.1",
"@actions/core": "^1.11.1"
}
}
}
21 changes: 16 additions & 5 deletions .github/actions/rnef-post-build/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Post Build'
description: 'Post Build info'
description: 'Post build comment for RNEF builds'

inputs:
artifact-url:
Expand All @@ -10,8 +10,19 @@ inputs:
required: true
github-token:
description: A GitHub Personal Access Token with write access to the project
required: false
default: ${{ github.token }}
required: true
runs:
using: 'node20'
main: 'index.js'
using: 'composite'
steps:
- name: Install dependencies
run: npm install
shell: bash
working-directory: ${{ github.action_path }}
- name: Post build
id: post-build
env:
INPUT_ARTIFACT_URL: ${{ inputs.artifact-url }}
INPUT_TITLE: ${{ inputs.title }}
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
run: node ${{ github.action_path }}/index.mjs
shell: bash
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
const core = require('@actions/core');
const github = require('@actions/github');
import core from "@actions/core";
import github from "@actions/github";

async function run() {
const token = core.getInput('github-token');
const titleInput = core.getInput('title');
const artifactUrl = core.getInput('artifact-url');
const token = core.getInput("github_token") || process.env.GITHUB_TOKEN;
if (!token) {
throw new Error("GitHub token is required");
}

const titleInput = core.getInput("title");
if (!titleInput) {
throw new Error("Title is required");
}

const artifactUrl = core.getInput("artifact_url");
if (!artifactUrl) {
throw new Error("Artifact URL is required");
}

const title = `## ${titleInput}`;
const body = `🔗 [Download link](${artifactUrl}).\n\n
Note: if the download link expires, please re-run the workflow to generate a new build.\n\n
*Generated at ${new Date().toISOString()} UTC*\n`;

const octokit = github.getOctokit(token);
const {data: comments} = await octokit.rest.issues.listComments({
const { data: comments } = await octokit.rest.issues.listComments({
...github.context.repo,
issue_number: github.context.issue.number,
});

const botComment = comments.find(
comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes(title),
(comment) =>
comment.user.login === "github-actions[bot]" &&
comment.body.includes(title)
);

if (botComment) {
Expand All @@ -29,14 +40,14 @@ Note: if the download link expires, please re-run the workflow to generate a new
comment_id: botComment.id,
body: `${title}\n\n${body}`,
});
console.log('Updated comment');
console.log("Updated comment");
} else {
await octokit.rest.issues.createComment({
...github.context.repo,
issue_number: github.context.issue.number,
body: `${title}\n\n${body}`,
});
console.log('Created comment');
console.log("Created comment");
}
}

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/rnef-post-build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.0"
}
}
}
21 changes: 0 additions & 21 deletions .github/workflows/main.yml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
destination: 'simulator' # or 'device'
scheme: 'YourScheme'
configuration: 'Debug'
github-token: ${{ secrets.GITHUB_TOKEN }}
# For device builds, add these:
# certificate-base64: ${{ secrets.CERTIFICATE_BASE64 }}
# certificate-password: ${{ secrets.CERTIFICATE_PASSWORD }}
Expand All @@ -45,7 +46,7 @@ jobs:

| Input | Description | Required | Default |
| ----------------------------- | ------------------------------------------ | -------- | --------------------- |
| `github-token` | GitHub Token | No | `${{ github.token }}` |
| `github-token` | GitHub Token | Yes | - |
| `working-directory` | Working directory for the build command | No | `.` |
| `destination` | Build destination: "simulator" or "device" | Yes | `simulator` |
| `scheme` | Xcode scheme | Yes | - |
Expand Down
9 changes: 7 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ branding:
inputs:
github-token:
description: GitHub Token
required: false
default: ${{ github.token }}
required: true
working-directory:
description: 'Working directory for the build command'
required: false
Expand Down Expand Up @@ -61,6 +60,10 @@ outputs:
runs:
using: 'composite'
steps:
- name: Install dependencies
run: npm install
shell: bash

- name: Validate inputs
run: |
if [ "${{ inputs.destination }}" != "simulator" ] && [ "${{ inputs.destination }}" != "device" ]; then
Expand Down Expand Up @@ -114,6 +117,7 @@ runs:
with:
name: ${{ env.ARTIFACT_NAME }}
re-sign: ${{ inputs.re-sign }}
github-token: ${{ inputs.github-token }}

- name: Set Provisioning Profile Path
run: |
Expand Down Expand Up @@ -256,3 +260,4 @@ runs:
with:
title: iOS ${{ inputs.configuration }} ${{ inputs.destination == 'simulator' && 'APP for simulators' || 'IPA for physical devices' }}
artifact-url: ${{ steps.upload-artifact.outputs.artifact-url || steps.find-artifact.outputs.artifact-url }}
github-token: ${{ inputs.github-token }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "action-ios",
"version": "1.0.0",
"description": "GitHub Action for building iOS applications using RNEF (React Native EAS Fastlane)",
"description": "GitHub Action for building iOS applications using RNEF (React Native Enterprise Framework)",
"main": "index.js",
"author": "",
"license": "MIT",
Expand Down