diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d8d688c9..89c81458 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,7 +25,6 @@ jobs: token: ${{ secrets.PAT_TOKEN }} - name: CFDI dependencies - id: cfdi uses: ./.github/actions/cfdi with: token: ${{ secrets.PAT_TOKEN }} @@ -52,63 +51,22 @@ jobs: - name: Publish (main) if: steps.branch.outputs.is_main == 'true' - run: | - SCOPES='${{ steps.cfdi.outputs.scopes }}' - - # --- Fase 1: Bump de TODOS los scopes --- - echo "========== PHASE 1: VERSION BUMP ==========" - for scope in $(echo "$SCOPES" | jq -r '.[]'); do - echo "=== Bumping $scope ===" - rush version --version-policy "$scope" --bump - done - - # --- Fase 2: Un solo publish (Rush maneja orden topológico) --- - echo "========== PHASE 2: PUBLISH ==========" - if rush publish -p -b main --set-access-level=public; then - git add -A - echo "✓ Publish exitoso" - else - echo "::error::Publish falló" - exit 1 - fi + run: rush publish -p -b main --include-all --set-access-level=public - name: Publish (prerelease) if: steps.branch.outputs.is_main == 'false' - run: | - TAG="${{ steps.branch.outputs.name }}" - SCOPES='${{ steps.cfdi.outputs.scopes }}' - - # --- Fase 1: Bump de TODOS los scopes --- - echo "========== PHASE 1: VERSION BUMP ==========" - for scope in $(echo "$SCOPES" | jq -r '.[]'); do - echo "=== Bumping $scope ===" - rush version --version-policy "$scope" --bump --override-bump prerelease --override-prerelease-id "$TAG" - done - - # --- Fase 2: Un solo publish (Rush maneja orden topológico) --- - echo "========== PHASE 2: PUBLISH ==========" - if rush publish --publish --tag "$TAG" --set-access-level=public --apply; then - git add -A - echo "✓ Publish exitoso" - else - echo "::error::Publish falló" - exit 1 - fi + run: rush publish --publish --tag ${{ steps.branch.outputs.name }} --include-all --set-access-level=public --apply - name: Commit version bumps run: | BRANCH="${{ steps.branch.outputs.name }}" git add -A - 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 + if [ "$BRANCH" = "main" ]; then + git commit -m "chore: release $(date +%Y-%m-%d)" || echo "No changes to commit" else - echo "No changes to commit" + git commit -m "chore: prerelease $BRANCH $(date +%Y-%m-%d)" || echo "No changes to commit" fi + git push origin $BRANCH - name: Create GitHub Releases run: node common/scripts/github-release.js diff --git a/common/config/rush/version-policies.json b/common/config/rush/version-policies.json index 16cd96b7..4687630a 100644 --- a/common/config/rush/version-policies.json +++ b/common/config/rush/version-policies.json @@ -29,24 +29,6 @@ "version": "4.0.16-dev.3", "nextBump": "patch" }, - { - "policyName": "pdf", - "definitionName": "lockStepVersion", - "version": "0.0.10-dev.0", - "nextBump": "prerelease" - }, - { - "policyName": "auth", - "definitionName": "lockStepVersion", - "version": "1.0.1", - "nextBump": "patch" - }, - { - "policyName": "curp", - "definitionName": "lockStepVersion", - "version": "0.0.10-beta.2", - "nextBump": "prerelease" - }, { "policyName": "rfc", "definitionName": "lockStepVersion", @@ -62,7 +44,7 @@ { "policyName": "openssl", "definitionName": "lockStepVersion", - "version": "0.0.17-dev.2", + "version": "0.0.17-dev.3", "nextBump": "patch" }, { @@ -106,95 +88,5 @@ "definitionName": "lockStepVersion", "version": "4.0.14-dev.2", "nextBump": "patch" - }, - { - "policyName": "designs", - "definitionName": "lockStepVersion", - "version": "4.0.13", - "nextBump": "patch" - }, - { - "policyName": "cleaner", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "estado", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "validador", - "definitionName": "lockStepVersion", - "version": "0.0.1-beta.0", - "nextBump": "prerelease" - }, - { - "policyName": "descarga", - "definitionName": "lockStepVersion", - "version": "0.0.1-beta.0", - "nextBump": "prerelease" - }, - { - "policyName": "cancelacion", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "recursos", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "scraper", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "opinion", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "contabilidad", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "captcha", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "retenciones", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "pacs", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "banxico", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" - }, - { - "policyName": "diot", - "definitionName": "lockStepVersion", - "version": "0.0.1", - "nextBump": "patch" } ] diff --git a/common/scripts/github-actions.js b/common/scripts/github-actions.js index 1a38dff1..62d0d6eb 100644 --- a/common/scripts/github-actions.js +++ b/common/scripts/github-actions.js @@ -1,4 +1,27 @@ +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: { @@ -178,6 +201,7 @@ 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 || []; @@ -195,18 +219,24 @@ module.exports = async ({ github, context, core }) => { commits = commits_local.map(({commit})=>commit) } const scopes = getScopes(commits); - console.log("scopes from commits", scopes); - - // 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); + console.log("commits", scopes); - core.setOutput('scopes', JSON.stringify(filteredScopes)); - core.setOutput('branch', branch); + 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); + } }; diff --git a/rush.json b/rush.json index 9ce4ca36..e8bb4d5a 100644 --- a/rush.json +++ b/rush.json @@ -120,7 +120,6 @@ { "packageName": "@cfdi/pdf", "projectFolder": "packages/cfdi/pdf", - "versionPolicyName": "pdf", "reviewCategory": "libraries", "shouldPublish": false, "tags": [ @@ -137,7 +136,6 @@ { "packageName": "@renapo/curp", "projectFolder": "packages/renapo/curp", - "versionPolicyName": "curp", "reviewCategory": "libraries", "shouldPublish": false, "tags": [ @@ -185,7 +183,6 @@ { "packageName": "@cfdi/estado", "projectFolder": "packages/cfdi/estado", - "versionPolicyName": "estado", "reviewCategory": "libraries", "shouldPublish": false, "tags": [ @@ -195,7 +192,6 @@ { "packageName": "@cfdi/descarga", "projectFolder": "packages/cfdi/descarga", - "versionPolicyName": "descarga", "reviewCategory": "libraries", "shouldPublish": false, "tags": [ @@ -205,7 +201,6 @@ { "packageName": "@sat/recursos", "projectFolder": "packages/sat/recursos", - "versionPolicyName": "recursos", "reviewCategory": "libraries", "shouldPublish": false }, @@ -233,14 +228,12 @@ { "packageName": "@cfdi/designs", "projectFolder": "packages/cfdi/designs", - "versionPolicyName": "designs", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@sat/auth", "projectFolder": "packages/sat/auth", - "versionPolicyName": "auth", "reviewCategory": "libraries", "shouldPublish": false, "tags": [ @@ -250,7 +243,6 @@ { "packageName": "@cfdi/validador", "projectFolder": "packages/cfdi/validador", - "versionPolicyName": "validador", "reviewCategory": "libraries", "shouldPublish": false, "tags": [ @@ -260,70 +252,60 @@ { "packageName": "@cfdi/cleaner", "projectFolder": "packages/cfdi/cleaner", - "versionPolicyName": "cleaner", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@cfdi/cancelacion", "projectFolder": "packages/cfdi/cancelacion", - "versionPolicyName": "cancelacion", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@cfdi/retenciones", "projectFolder": "packages/cfdi/retenciones", - "versionPolicyName": "retenciones", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@sat/scraper", "projectFolder": "packages/sat/scraper", - "versionPolicyName": "scraper", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@sat/opinion", "projectFolder": "packages/sat/opinion", - "versionPolicyName": "opinion", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@sat/contabilidad", "projectFolder": "packages/sat/contabilidad", - "versionPolicyName": "contabilidad", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@sat/captcha", "projectFolder": "packages/sat/captcha", - "versionPolicyName": "captcha", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@sat/pacs", "projectFolder": "packages/sat/pacs", - "versionPolicyName": "pacs", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@sat/banxico", "projectFolder": "packages/sat/banxico", - "versionPolicyName": "banxico", "reviewCategory": "libraries", "shouldPublish": false }, { "packageName": "@sat/diot", "projectFolder": "packages/sat/diot", - "versionPolicyName": "diot", "reviewCategory": "libraries", "shouldPublish": false },