diff --git a/.github/workflows/configured.yml b/.github/workflows/configured.yml deleted file mode 100644 index 756e92c..0000000 --- a/.github/workflows/configured.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: "Frontend: Configured" - -on: - workflow_call: - outputs: - exists: - description: "Exists" - value: ${{ jobs.exists.outputs.exists }} - -jobs: - exists: - name: Exists - runs-on: ubuntu-latest - outputs: - exists: ${{ steps.check_files.outputs.files_exists }} - steps: - - uses: actions/checkout@v4 - - name: Check file existence - id: check_files - uses: andstor/file-existence-action@v1 - with: - files: "package.json" diff --git a/install/action.yml b/install/action.yml new file mode 100644 index 0000000..c253766 --- /dev/null +++ b/install/action.yml @@ -0,0 +1,31 @@ +name: "Install Dependencies" +description: "Install npm dependencies" + +inputs: + npm-not-ci: + description: "Run npm install instead of npm ci" + default: "false" + required: false + npm-install-force: + description: "Force npm install" + default: "false" + required: false + +runs: + using: composite + steps: + - name: Install dependencies + run: | + CMD="npm" + if [ "${{ inputs.npm-not-ci }}" = "true" ]; then + CMD="${CMD} install" + else + CMD="${CMD} ci" + fi + + if [ "${{ inputs.npm-install-force }}" = "true" ]; then + CMD="${CMD} --force" + fi + + ${CMD} + shell: bash diff --git a/package-lock.json b/package-lock.json index 0dd868e..4455333 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,7 +1,7 @@ { "name": "@vality/action-frontend", "version": "0.2.0", - "lockfileVersion": 2, + "lockfileVersion": 3, "requires": true, "packages": { "": { @@ -9,13 +9,14 @@ "version": "0.2.0", "license": "Apache-2.0", "dependencies": { - "prettier": "^3.0.3" + "prettier": "^3.5.3" } }, "node_modules/prettier": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", - "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", + "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", + "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" }, @@ -26,12 +27,5 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } } - }, - "dependencies": { - "prettier": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", - "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==" - } } } diff --git a/package.json b/package.json index 8010252..15a7bdc 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,6 @@ }, "homepage": "https://github.com/valitydev/action-frontend#readme", "dependencies": { - "prettier": "^3.0.3" + "prettier": "^3.5.3" } } diff --git a/publish/action.yml b/publish/action.yml index e7b1e69..4e77009 100644 --- a/publish/action.yml +++ b/publish/action.yml @@ -5,29 +5,52 @@ inputs: npm-token: description: The NPM access token to use when publishing required: true - version-up: - description: Version up - default: "true" + npm-skip-version-up: + description: Version not up + default: "false" + required: false + npm-version-tag: + description: Version tag + default: "" required: false directory: description: Directory default: "./" required: false + pr-label: + description: PR label for publish (publish {label}) + default: "" + required: false + pr-only-labeled: + description: Only publish if the PR is labeled + default: "false" + required: false runs: using: composite steps: - - name: Publish NPM - if: inputs.version-up == 'false' + - name: Package version up + if: inputs.npm-skip-version-up == 'false' working-directory: ${{ inputs.directory }} - run: npm publish + run: | + PREFIX="" + if [ "${{ inputs.npm-version-tag }}" != "" ]; then + PREFIX="${{ inputs.npm-version-tag }}-${{ github.event.number }}-" + fi + SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7) + npm version prerelease --preid "${PREFIX}${SHA}" --no-git-tag-version shell: bash env: NODE_AUTH_TOKEN: ${{ inputs.npm-token }} - - name: Publish NPM (version up) - if: inputs.version-up == 'true' + - name: Publish + if: > + inputs.pr-only-labeled == 'false' + || (contains(github.event.pull_request.labels.*.name, 'publish') + || (inputs.pr-label != '' + && contains(github.event.pull_request.labels.*.name, format('publish {0}', inputs.pr-label)))) working-directory: ${{ inputs.directory }} - run: npm publish || (npm version prerelease --preid ${GITHUB_SHA::7} --no-git-tag-version && npm publish) + run: | + npm publish ${{ inputs.npm-version-tag != '' && format('--tag {0}', inputs.npm-version-tag) || '' }} shell: bash env: NODE_AUTH_TOKEN: ${{ inputs.npm-token }} diff --git a/setup-install/action.yml b/setup-install/action.yml new file mode 100644 index 0000000..548c36e --- /dev/null +++ b/setup-install/action.yml @@ -0,0 +1,29 @@ +name: "Setup NodeJS and Install" +description: "Setup NodeJS & install dependencies" + +inputs: + node-version: + description: "NodeJS version" + default: "lts/*" + required: false + npm-not-ci: + description: "Run npm install instead of npm ci" + default: "false" + required: false + npm-install-force: + description: "Force npm install" + default: "false" + required: false + +runs: + using: composite + steps: + - name: Setup NodeJS + uses: ../setup + with: + node-version: ${{ inputs.node-version }} + - name: Install dependencies + uses: ../install + with: + npm-not-ci: ${{ inputs.npm-not-ci }} + npm-install-force: ${{ inputs.npm-install-force }} diff --git a/setup/action.yml b/setup/action.yml index 7b09a0d..d85d83c 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -4,14 +4,14 @@ description: "Setup NodeJS" inputs: node-version: description: "NodeJS version" - default: "20" + default: "lts/*" required: false runs: using: composite steps: - name: Setup NodeJS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ inputs.node-version }} cache: "npm"