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
5 changes: 4 additions & 1 deletion .github/actions/cfdi/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ inputs:

outputs:
scopes:
description: 'JSON array of bumped scopes'
description: 'JSON array of publishable scopes'
value: ${{ steps.script.outputs.scopes }}
branch:
description: 'Target branch name'
value: ${{ steps.script.outputs.branch }}

runs:
using: 'composite'
Expand Down
48 changes: 39 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,60 @@ jobs:
if: steps.branch.outputs.is_main == 'true'
run: |
SCOPES='${{ steps.cfdi.outputs.scopes }}'
FAILED=""
for scope in $(echo "$SCOPES" | jq -r '.[]'); do
echo "Publishing version-policy: $scope"
rush publish -p -b main --version-policy "$scope" --include-all --set-access-level=public
echo "=== Publishing $scope ==="
rush version --version-policy "$scope" --bump
if rush publish -p -b main --version-policy "$scope" --include-all --set-access-level=public; then
git add -A
echo "✓ $scope published"
else
FAILED="$FAILED $scope"
git checkout -- .
echo "::warning::✗ $scope failed, reverted"
fi
done
if [ -n "$FAILED" ]; then
echo "::error::Failed scopes:$FAILED"
exit 1
fi

- name: Publish (prerelease)
if: steps.branch.outputs.is_main == 'false'
run: |
TAG="${{ steps.branch.outputs.name }}"
SCOPES='${{ steps.cfdi.outputs.scopes }}'
FAILED=""
for scope in $(echo "$SCOPES" | jq -r '.[]'); do
echo "Publishing version-policy: $scope"
rush publish --publish --version-policy "$scope" --tag ${{ steps.branch.outputs.name }} --include-all --set-access-level=public --apply
echo "=== Publishing $scope ==="
rush version --version-policy "$scope" --bump --override-bump prerelease --override-prerelease-id "$TAG"
if rush publish --publish --version-policy "$scope" --tag "$TAG" --include-all --set-access-level=public --apply; then
git add -A
echo "✓ $scope published"
else
FAILED="$FAILED $scope"
git checkout -- .
echo "::warning::✗ $scope failed, reverted"
fi
done
if [ -n "$FAILED" ]; then
echo "::error::Failed scopes:$FAILED"
exit 1
fi

- name: Commit version bumps
run: |
BRANCH="${{ steps.branch.outputs.name }}"
git add -A
if [ "$BRANCH" = "main" ]; then
git commit -m "chore: release $(date +%Y-%m-%d)" || echo "No changes to commit"
if [ -n "$(git diff --cached --name-only)" ]; then
if [ "$BRANCH" = "main" ]; then
git commit -m "chore: release $(date +%Y-%m-%d)"
else
git commit -m "chore: prerelease $BRANCH $(date +%Y-%m-%d)"
fi
git push origin $BRANCH
else
git commit -m "chore: prerelease $BRANCH $(date +%Y-%m-%d)" || echo "No changes to commit"
echo "No changes to commit"
fi
git push origin $BRANCH

- name: Create GitHub Releases
run: node common/scripts/github-release.js
Expand Down
12 changes: 6 additions & 6 deletions common/config/rush/version-policies.json

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

56 changes: 12 additions & 44 deletions common/scripts/github-actions.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@

async function execa(command, params) {
const { spawn } = require('child_process');
const child = spawn(command, params);

let data = '';
for await (const chunk of child.stdout) {
//console.log('stdout chunk: ' + chunk);
data += chunk;
}
let error = '';
for await (const chunk of child.stderr) {
//console.error('stderr chunk: ' + chunk);
error += chunk;
}
const exitCode = await new Promise((resolve, reject) => {
child.on('close', resolve);
});

if (exitCode) {
throw new Error(`subprocess error exit ${exitCode}, ${error}`);
}
return data;
}
function getDependences(scope) {
const dependencies = {
xml: {
Expand Down Expand Up @@ -201,7 +178,6 @@ module.exports = async ({ github, context, core }) => {
console.log("branch:", branch);
console.log("eventName:", context.eventName);

const branchs = ['next','beta', 'alpha','dev']
const eventName = context.eventName
let commits = context.payload.commits || [];

Expand All @@ -219,26 +195,18 @@ module.exports = async ({ github, context, core }) => {
commits = commits_local.map(({commit})=>commit)
}
const scopes = getScopes(commits);
console.log("commits", scopes);
console.log("scopes from commits", scopes);

for (var i = 0; i < scopes.length; i++) {
const scope = scopes[i];
const comands = [
'version',
'--version-policy',
scope,
'--bump',
]
if (branchs.includes(branch)) {
comands.push('--override-bump');
comands.push('prerelease');
comands.push('--override-prerelease-id');
comands.push(branch);
}
console.log(comands);
const data = await execa('rush', comands);
console.log(data);
}
// Filtrar scopes que no tienen shouldPublish: true
const rushJson = JSON.parse(require('fs').readFileSync('./rush.json', 'utf8'));
const publishablePolicies = new Set(
rushJson.projects
.filter(p => p.shouldPublish && p.versionPolicyName)
.map(p => p.versionPolicyName)
);
const filteredScopes = scopes.filter(s => publishablePolicies.has(s));
console.log("publishable scopes", filteredScopes);

core.setOutput('scopes', JSON.stringify(scopes));
core.setOutput('scopes', JSON.stringify(filteredScopes));
core.setOutput('branch', branch);
};
2 changes: 1 addition & 1 deletion packages/cfdi/catalogos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cfdi/catalogos",
"version": "4.0.16-dev.0",
"version": "4.0.16-dev.1",
"license": "MIT",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/cfdi/complementos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cfdi/complementos",
"version": "4.0.17-dev.0",
"version": "4.0.17-dev.1",
"description": "Libreria para generar complementos del cfdi V4.0",
"homepage": "https://cfdi.recreando.dev",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/cfdi/csd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cfdi/csd",
"version": "4.0.16-dev.0",
"version": "4.0.16-dev.1",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/cfdi/csf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cfdi/csf",
"version": "4.0.16-dev.0",
"version": "4.0.16-dev.1",
"license": "MIT",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/cfdi/xml/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cfdi/xml",
"version": "4.0.18-dev.0",
"version": "4.0.18-dev.1",
"description": "Libreria para crear y sellar xml cfdi V4.0",
"homepage": "https://cfdi.recreando.dev",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/cfdi/xsd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cfdi/xsd",
"version": "4.0.17-dev.0",
"version": "4.0.17-dev.1",
"license": "MIT",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down
Loading