diff --git a/.github/workflows/build_check.yaml b/.github/workflows/build_check.yaml new file mode 100644 index 0000000..4ba25cb --- /dev/null +++ b/.github/workflows/build_check.yaml @@ -0,0 +1,28 @@ +name: Build Check on PR + +on: + pull_request: + branches: + - v2 + - v2-develop + - alpha + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.5.0' + + - name: Install dependencies + run: npm install + + - name: Run build + run: npm run build \ No newline at end of file diff --git a/.github/workflows/npm_publish.yaml b/.github/workflows/npm_publish.yaml new file mode 100644 index 0000000..3e9e639 --- /dev/null +++ b/.github/workflows/npm_publish.yaml @@ -0,0 +1,39 @@ +name: Manual NPM publish + +on: + workflow_dispatch: + inputs: + version_tag: + description: 'Version tag' + required: true + +concurrency: + group: "release" + cancel-in-progress: false + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '20.5.0' + registry-url: 'https://registry.npmjs.org/' + + - name: Checkout Repository + uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.version_tag }} + + - name: Install Dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: NPM publish + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 43c883e..8b93865 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,5 +1,8 @@ name: Release +env: + LIBRARY_NAME: "gisce/powerp.js" + on: push: branches: @@ -8,21 +11,29 @@ on: - alpha workflow_dispatch: +concurrency: + group: "release" + cancel-in-progress: false + jobs: release: name: Release runs-on: ubuntu-latest + outputs: + release_type: ${{ steps.get_release_type.outputs.release_type }} + tag_name: ${{ steps.get_tag_name.outputs.tag_name }} + branch_name: ${{ steps.get_branch_name.outputs.branch_name }} steps: - - name: Checkout Repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup Node.js uses: actions/setup-node@v2 with: node-version: '20.5.0' + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: Install Dependencies run: npm ci @@ -31,3 +42,52 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_PAT }} NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} run: npx semantic-release + + - name: Capture Release Type + id: get_release_type + run: | + if [ -f ".release-type" ]; then + release_type=$(cat .release-type) + echo "release_type=$release_type" >> $GITHUB_OUTPUT + else + echo "release_type=none" >> $GITHUB_OUTPUT + fi + shell: bash + + - name: Capture Tag Name + id: get_tag_name + run: | + if [ -f ".release-tag" ]; then + tag_name=$(cat .release-tag) + echo "tag_name=$tag_name" >> $GITHUB_OUTPUT + else + echo "tag_name=none" >> $GITHUB_OUTPUT + fi + shell: bash + + - name: Capture Branch Name + id: get_branch_name + run: echo "branch_name=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT + shell: bash + + update-dependents: + name: Update dependent projects + needs: release + if: needs.release.outputs.release_type != 'none' + runs-on: ubuntu-latest + strategy: + matrix: + include: + - project: "gisce/webclient" + # modify this in case that branches are not equivalent and exist between projects + branch: ${{ needs.release.outputs.branch_name }} + steps: + - name: Call update version dependency flow for each project + uses: gisce/create-update-version-pr@v0.0.9 + with: + dependentProject: ${{ matrix.project }} + tagName: ${{ needs.release.outputs.tag_name }} + dependentProjectBranch: ${{ matrix.branch }} + libraryName: ${{ env.LIBRARY_NAME }} + githubToken: ${{ secrets.GH_PAT }} + releaseType: ${{ needs.release.outputs.release_type }} \ No newline at end of file diff --git a/.github/workflows/update_dependent_projects_alpha.yaml b/.github/workflows/update_dependent_projects_alpha.yaml deleted file mode 100644 index fd0e870..0000000 --- a/.github/workflows/update_dependent_projects_alpha.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Update dependent projects (alpha) - -on: - release: - types: [published] - workflow_dispatch: - -env: - LIBRARY_NAME: "gisce/powerp.js" - -jobs: - update-dependents: - if: github.event.release.prerelease == true && contains(github.event.release.tag_name, '-alpha.') && !contains(github.event.release.tag_name, '-rc.') - runs-on: ubuntu-latest - strategy: - matrix: - include: - - project: "gisce/webclient" - branch: "alpha" - steps: - - name: Call Reusable Workflow for each project - uses: gisce/create-update-version-pr@v0.0.5 - with: - dependentProject: ${{ matrix.project }} - tagName: ${{ github.event.release.tag_name }} - dependentProjectBranch: ${{ matrix.branch }} - libraryName: ${{ env.LIBRARY_NAME }} - githubToken: ${{ secrets.GH_PAT }} diff --git a/.github/workflows/update_dependent_projects_v2-develop.yaml b/.github/workflows/update_dependent_projects_v2-develop.yaml deleted file mode 100644 index bf94e66..0000000 --- a/.github/workflows/update_dependent_projects_v2-develop.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Update dependent projects (v2-develop) - -on: - release: - types: [published] - workflow_dispatch: - -env: - LIBRARY_NAME: "gisce/powerp.js" - -jobs: - update-dependents: - if: github.event.release.prerelease == true && !contains(github.event.release.tag_name, '-alpha.') && contains(github.event.release.tag_name, '-rc.') - runs-on: ubuntu-latest - strategy: - matrix: - include: - - project: "gisce/webclient" - branch: "v2-develop" - steps: - - name: Call Reusable Workflow for each project - uses: gisce/create-update-version-pr@v0.0.5 - with: - dependentProject: ${{ matrix.project }} - tagName: ${{ github.event.release.tag_name }} - dependentProjectBranch: ${{ matrix.branch }} - libraryName: ${{ env.LIBRARY_NAME }} - githubToken: ${{ secrets.GH_PAT }} diff --git a/.github/workflows/update_dependent_projects_v2.yaml b/.github/workflows/update_dependent_projects_v2.yaml deleted file mode 100644 index ee556fd..0000000 --- a/.github/workflows/update_dependent_projects_v2.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Update dependent projects (v2) - -on: - release: - types: [published] - workflow_dispatch: - -env: - LIBRARY_NAME: "gisce/powerp.js" - -jobs: - update-dependents: - if: github.event.release.prerelease == false && contains(github.event.release.tag_name, 'v2') - runs-on: ubuntu-latest - strategy: - matrix: - include: - - project: "gisce/webclient" - branch: "v2" - steps: - - name: Call Reusable Workflow for each project - uses: gisce/create-update-version-pr@v0.0.5 - with: - dependentProject: ${{ matrix.project }} - tagName: ${{ github.event.release.tag_name }} - dependentProjectBranch: ${{ matrix.branch }} - libraryName: ${{ env.LIBRARY_NAME }} - githubToken: ${{ secrets.GH_PAT }} diff --git a/package-lock.json b/package-lock.json index 3a83b88..966dfdb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gisce/powerp.js", - "version": "2.3.1", + "version": "2.3.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gisce/powerp.js", - "version": "2.3.1", + "version": "2.3.2", "license": "MIT", "devDependencies": { "@commitlint/cli": "^18.4.3", diff --git a/package.json b/package.json index 90d0339..c8d3244 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gisce/powerp.js", - "version": "2.3.1", + "version": "2.3.2", "description": "PowERP Javascript Client", "module": "./dist/powerpjs.es.js", "files": [ @@ -115,7 +115,13 @@ "failComment": false } ], - "@semantic-release/git" + "@semantic-release/git", + [ + "@semantic-release/exec", + { + "prepareCmd": "echo ${nextRelease.type} > .release-type && echo ${nextRelease.gitTag} > .release-tag" + } + ] ] } }