From 1ed411e5006a5a477c8002765977f16e1ff755a5 Mon Sep 17 00:00:00 2001 From: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> Date: Wed, 1 Feb 2023 21:34:59 -0700 Subject: [PATCH] feat: Adding Release Automation (#1122) * Adding release automation step * blocking step * unneeded check * path renaming * feat: :recycle: Refactor ci:build:stable * feat: :package: Create Release Asset for Stable Env --------- Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> --- .github/workflows/ci.yml | 69 +++++++++++++++++++++++++++++++++++++--- package.json | 6 ++-- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16920b2c7..4021e75e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,10 +24,10 @@ jobs: steps: - name: Check out Git repository - uses: actions/checkout@v1 + uses: actions/checkout@v3.3.0 - name: Install Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v3.6.0 with: node-version: 18 @@ -39,7 +39,7 @@ jobs: npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"} - name: Restore .cache - uses: actions/cache@v2 + uses: actions/cache@v3.2.4 id: cache with: path: ${{ github.workspace }}/.cache @@ -50,7 +50,7 @@ jobs: - name: Restore node_modules id: yarn-cache - uses: actions/cache@v2 + uses: actions/cache@v3.2.4 with: path: node_modules key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} @@ -84,7 +84,7 @@ jobs: # - action artifacts can be downloaded for 90 days, then are removed by github # - binaries in PRs from forks won't be signed - name: Attach produced packages to Github Action - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3.1.2 with: name: built-on-${{ matrix.os }} path: build/ipfs_companion*.* @@ -92,3 +92,62 @@ jobs: - name: Show Cache run: du -h ${{ github.workspace }}/.cache/* || true + + release-pr: + runs-on: ubuntu-latest + needs: [test] + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + steps: + - uses: google-github-actions/release-please-action@v3.7.3 + with: + release-type: node + package-name: ipfs-companion + changelog-notes-type: github + command: release-pr + + release-assets: + runs-on: ubuntu-latest + needs: [test] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + steps: + - name: Check out Git repository + uses: actions/checkout@v3.3.0 + + - name: Install Node.js + uses: actions/setup-node@v3.6.0 + with: + node-version: 18 + + - name: Restore .cache + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ github.workspace }}/.cache + key: ${{ runner.os }}-${{ hashFiles('package*json', 'package-lock.json', '*config.js') }} + restore-keys: | + ${{ runner.os }}-${{ hashFiles('package*json', 'package-lock.json', '*config.js') }} + ${{ runner.os }}- + + - name: Restore node_modules + id: yarn-cache + uses: actions/cache@v3.2.4 + with: + path: node_modules + key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} + + - name: Install dependencies + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: npm run ci:install + + - name: Build Stable Release + run: npm run ci:build:stable + + - name: Release + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 + with: + files: build/*.zip + fail_on_unmatched_files: true + generate_release_notes: true + draft: true + append_body: true + body: 'Automated Release, please upload artifacts to respective webstores and mark this draft as released.' diff --git a/package.json b/package.json index ab0dee153..8356a3422 100644 --- a/package.json +++ b/package.json @@ -56,10 +56,12 @@ "ci": "run-s ci:*", "ci:install": "npm ci --prefer-offline --no-audit --progress=false", "ci:build": "npm run build", + "ci:build:stable": "RELEASE_CHANNEL=stable npm run ci:build", + "ci:build:beta": "RELEASE_CHANNEL=beta npm run ci:build", "ci:test": "npm test", "ci:lint": "npm run lint", - "beta-build": "docker rmi -f ipfs-companion-beta-build && docker build -t ipfs-companion-beta-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm --net=host -e RELEASE_CHANNEL=beta -v $(pwd)/build:/home/node/app/build ipfs-companion-beta-build npm run ci:build", - "release-build": "docker rmi -f ipfs-companion-release-build && docker build -t ipfs-companion-release-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm --net=host -e RELEASE_CHANNEL=stable -v $(pwd)/build:/home/node/app/build ipfs-companion-release-build npm run ci:build", + "beta-build": "docker rmi -f ipfs-companion-beta-build && docker build -t ipfs-companion-beta-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm --net=host -v $(pwd)/build:/home/node/app/build ipfs-companion-beta-build npm run ci:build:beta", + "release-build": "docker rmi -f ipfs-companion-release-build && docker build -t ipfs-companion-release-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm --net=host -v $(pwd)/build:/home/node/app/build ipfs-companion-release-build npm run ci:build:stable", "dev-build": "npm ci && cross-env NODE_ENV='development' npm run build", "yarn-build": "npm run dev-build", "compose:e2e:prepare": "docker compose --file docker-compose.e2e.yml pull && docker compose --file docker-compose.e2e.yml build",