From 736631eb94ac96dfc4c017a67a4caadeb26cd2cb Mon Sep 17 00:00:00 2001 From: HIROSE Masaya Date: Mon, 5 Feb 2024 19:30:24 +0900 Subject: [PATCH 1/5] chore: Added GitHub Actions for npm publish --- .github/workflows/beta.yml | 57 ++++++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 55 ++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 .github/workflows/beta.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml new file mode 100644 index 0000000..9be4f03 --- /dev/null +++ b/.github/workflows/beta.yml @@ -0,0 +1,57 @@ +name: Publish beta version to npm + +on: + push: + tags: + - '*-beta.*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: 'recursive' + + - name: Check for Pre-release Version in package.json + id: check + run: | + version=$(node -p "require('./package.json').version") + echo "version=$version" >> $GITHUB_ENV + if [[ "$version" == *"-beta"* ]]; then + echo "Pre-release version detected in package.json: $version" + echo "prerelease=true" >> $GITHUB_ENV + else + echo "No pre-release version detected in package.json." + echo "prerelease=false" >> $GITHUB_ENV + fi + + - name: Abort if not a Pre-release + if: env.prerelease == 'false' + run: | + echo "Aborting: No pre-release version detected in package.json despite '-beta' tag." + exit 1 + + - name: Check if version has been published + id: check_version + run: | + if git rev-parse "v$version" >/dev/null 2>&1; then + echo "exists=true" >> $GITHUB_ENV + else + echo "exists=false" >> $GITHUB_ENV + echo "new_tag=v$version" >> $GITHUB_ENV + fi + + - name: Setup Node.js + if: env.exists == 'false' + uses: actions/setup-node@v3 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + + - name: Publish to npm + if: env.exists == 'false' + run: npm publish --tag beta + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..da07e60 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,55 @@ +name: Publish to npm + +on: + pull_request: + branches: + - master + types: [closed] + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: 'recursive' + + - name: Check if version has been published + id: check_version + run: | + version=$(node -p "require('./package.json').version") + echo "VERSION=$version" >> $GITHUB_ENV + if git rev-parse "$version" >/dev/null 2>&1; then + echo "exists=true" >> $GITHUB_ENV + else + echo "exists=false" >> $GITHUB_ENV + echo "new_tag=$version" >> $GITHUB_ENV + fi + + - name: Create Release + if: env.exists == 'false' + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.new_tag }} + release_name: Release ${{ env.new_tag }} + draft: false + prerelease: false + + - name: Setup Node.js + if: env.exists == 'false' + uses: actions/setup-node@v3 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + + - name: Publish to npm + if: env.exists == 'false' + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 7fcdfbb4f98149af4af371f9c424b98c6db040aa Mon Sep 17 00:00:00 2001 From: HIROSE Masaya Date: Tue, 6 Feb 2024 19:56:12 +0900 Subject: [PATCH 2/5] refactor: Applied feedback --- .github/workflows/beta.yml | 37 +++++++++---------------------------- .github/workflows/main.yml | 4 ---- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 9be4f03..9600d60 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -14,42 +14,23 @@ jobs: fetch-depth: 0 submodules: 'recursive' - - name: Check for Pre-release Version in package.json - id: check - run: | - version=$(node -p "require('./package.json').version") - echo "version=$version" >> $GITHUB_ENV - if [[ "$version" == *"-beta"* ]]; then - echo "Pre-release version detected in package.json: $version" - echo "prerelease=true" >> $GITHUB_ENV - else - echo "No pre-release version detected in package.json." - echo "prerelease=false" >> $GITHUB_ENV - fi - - - name: Abort if not a Pre-release - if: env.prerelease == 'false' - run: | - echo "Aborting: No pre-release version detected in package.json despite '-beta' tag." - exit 1 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' - name: Check if version has been published - id: check_version run: | - if git rev-parse "v$version" >/dev/null 2>&1; then + version=$(node -p "require('./package.json').version") + echo "version=$version" >> $GITHUB_ENV + if git rev-parse "$version" >/dev/null 2>&1; then echo "exists=true" >> $GITHUB_ENV else echo "exists=false" >> $GITHUB_ENV - echo "new_tag=v$version" >> $GITHUB_ENV + echo "new_tag=$version" >> $GITHUB_ENV fi - - name: Setup Node.js - if: env.exists == 'false' - uses: actions/setup-node@v3 - with: - node-version: '20.x' - registry-url: 'https://registry.npmjs.org' - - name: Publish to npm if: env.exists == 'false' run: npm publish --tag beta diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index da07e60..8cc6011 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,10 +1,6 @@ name: Publish to npm on: - pull_request: - branches: - - master - types: [closed] push: branches: - master From b44ef1ebc2d3d37b014ce613de9761cef9337ce4 Mon Sep 17 00:00:00 2001 From: HIROSE Masaya Date: Wed, 7 Feb 2024 10:43:49 +0900 Subject: [PATCH 3/5] refactor: Changed variable --- .github/workflows/beta.yml | 12 ------------ .github/workflows/main.yml | 10 +++++----- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 9600d60..cc03ab5 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -20,19 +20,7 @@ jobs: node-version: '20.x' registry-url: 'https://registry.npmjs.org' - - name: Check if version has been published - run: | - version=$(node -p "require('./package.json').version") - echo "version=$version" >> $GITHUB_ENV - if git rev-parse "$version" >/dev/null 2>&1; then - echo "exists=true" >> $GITHUB_ENV - else - echo "exists=false" >> $GITHUB_ENV - echo "new_tag=$version" >> $GITHUB_ENV - fi - - name: Publish to npm - if: env.exists == 'false' run: npm publish --tag beta env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8cc6011..6acd637 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,14 +20,14 @@ jobs: version=$(node -p "require('./package.json').version") echo "VERSION=$version" >> $GITHUB_ENV if git rev-parse "$version" >/dev/null 2>&1; then - echo "exists=true" >> $GITHUB_ENV + echo "git_tag_exists=true" >> $GITHUB_ENV else - echo "exists=false" >> $GITHUB_ENV + echo "git_tag_exists=false" >> $GITHUB_ENV echo "new_tag=$version" >> $GITHUB_ENV fi - name: Create Release - if: env.exists == 'false' + if: env.git_tag_exists == 'false' uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -38,14 +38,14 @@ jobs: prerelease: false - name: Setup Node.js - if: env.exists == 'false' + if: env.git_tag_exists == 'false' uses: actions/setup-node@v3 with: node-version: '20.x' registry-url: 'https://registry.npmjs.org' - name: Publish to npm - if: env.exists == 'false' + if: env.git_tag_exists == 'false' run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 64e309b141df95c0a094da90baa66aeb01c50412 Mon Sep 17 00:00:00 2001 From: HIROSE Masaya Date: Tue, 13 Feb 2024 14:45:16 +0900 Subject: [PATCH 4/5] chore: Added npm ci --- .github/workflows/beta.yml | 3 +++ .github/workflows/main.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index cc03ab5..c2e85eb 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -20,6 +20,9 @@ jobs: node-version: '20.x' registry-url: 'https://registry.npmjs.org' + - name: Install dependencies + run: npm ci + - name: Publish to npm run: npm publish --tag beta env: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6acd637..393af91 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,6 +44,9 @@ jobs: node-version: '20.x' registry-url: 'https://registry.npmjs.org' + - name: Install dependencies + run: npm ci + - name: Publish to npm if: env.git_tag_exists == 'false' run: npm publish From e9eda6c3b848d85cd3348a398e2c3c82e4c66b41 Mon Sep 17 00:00:00 2001 From: HIROSE Masaya Date: Mon, 24 Jun 2024 16:03:55 +0900 Subject: [PATCH 5/5] chore: Updated README --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 5477d6a..e203817 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,19 @@ The problem might be in the installation of Node.js. If you installed Node.js th For more information about managing multiple Node.js versions, refer to this [documentation](https://docs.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-windows). 4. Install the Monaca CLI again. 5. The login should be working now. + +### GitHub Actions + +- submodules are recursively installed by adding the submodules: 'recursive' option. + +#### When merged/pushed to master branch + +- Get version from package.json +- If version does not exist in GitHub tags + - Tag it + - Run npm publish + +#### When tagged as -beta.* + +- Run npm publish --beta +