From 8201a0251d49913f0397a2644f72ba3967ec832f Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 14 Oct 2020 13:27:47 +0200 Subject: [PATCH] feat: automated Chocolatey publishing (#1697) --- .github/workflows/chocolatey.yml | 47 ++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 1 - README.md | 12 +------- pkgs/chocolatey/README.md | 4 +++ 4 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/chocolatey.yml create mode 100644 pkgs/chocolatey/README.md diff --git a/.github/workflows/chocolatey.yml b/.github/workflows/chocolatey.yml new file mode 100644 index 000000000..fae667603 --- /dev/null +++ b/.github/workflows/chocolatey.yml @@ -0,0 +1,47 @@ +name: chocolatey + +on: + release: + types: [published] + +env: + XDG_CACHE_HOME: ${{ github.workspace }}/.cache + ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron + ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder + release_name: ${{ github.event.release.name }} + release_tag: ${{ github.event.release.tag_name }} + +jobs: + publish: + runs-on: windows-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v1 + + - name: Install Node.js for update script + uses: actions/setup-node@v1 + with: + node-version: 12.x + + - name: Cache bigger downloads + uses: actions/cache@v2 + id: cache + with: + path: ${{ github.workspace }}/.cache + key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'electron-builder.yml') }} + restore-keys: | + ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'electron-builder.yml') }} + ${{ runner.os }}- + + - name: Install dependencies + run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm + + - name: Download .exe, update version, URL and hash + run: node pkgs\chocolatey\update.js ${{ env.release_name }} + + - name: Create .nupkg + run: cd pkgs\chocolatey && choco pack + + - name: Publish to Chocolatey + run: choco push pkgs/chocolatey/ipfs-desktop.${{ env.release_name }}.nupkg --key ${{ secrets.chocolatey_key }} --source "https://push.chocolatey.org" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22e1c3666..95264ac5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,6 @@ jobs: # Apple signing mac_certs: ${{ secrets.mac_certs }} mac_certs_password: ${{ secrets.mac_certs_password }} - # TODO: secrets forsnap, chocolatey env: CI_BUILD_TAG: ${{steps.tag.outputs.tag}} # used by --publish onTag # Apple notarization diff --git a/README.md b/README.md index e2a5da8ba..dc6a9ef1e 100644 --- a/README.md +++ b/README.md @@ -136,18 +136,8 @@ Other languages are periodically pulled from [Transifex](https://www.transifex.c - Update links and badges in `README.md` to point to the new version (`A.B.C`) - Update `CHANGELOG.md` with details from release/release draft - Update selected package managers - - Wait for Github Action to finish and confirm it updated [Snap](https://snapcraft.io/ipfs-desktop). + - Wait for CI to finish and confirm it updated [Snap](https://snapcraft.io/ipfs-desktop) and is at least pending review on [Chocolatey](https://chocolatey.org/packages/ipfs-desktop#versionhistory). - Update [Homebrew Cask](https://github.com/Homebrew/homebrew-cask/blob/master/CONTRIBUTING.md#updating-a-cask). - - Update Chocolatey package: - 1. Wait for the artefact on the [releases page](https://github.com/ipfs-shipyard/ipfs-desktop/releases) - 2. Run `node pkgs/chocolatey/update.js A.B.C` - this script will update version to `A.B.C` in a few files: - 1. Update the version number on [ipfs-desktop.nuspec](./pkgs/chocolatey/ipfs-desktop.nuspec#L5) - 2. Update the binary URL on [chocolateyinstall.ps1](./pkgs/chocolatey/tools/chocolateyinstall.ps1#L3) - 3. Update the SHA256 of the binary on [chocolateyinstall.ps1](./pkgs/chocolatey/tools/chocolateyinstall.ps1#L4) - 3. Next, create `.nupkg` file and publish it: - 1. `cd pkgs/chocolatey` - 2. `choco pack` - generates a `.nupkg` file. - 3. `choco push $generated_nupkg --key $api --source https://push.chocolatey.org` - To start work on the next version, bump the version in the `package.json` ### Manual notarization (Fallback in-case CI is not doing it correctly) diff --git a/pkgs/chocolatey/README.md b/pkgs/chocolatey/README.md new file mode 100644 index 000000000..f61de6759 --- /dev/null +++ b/pkgs/chocolatey/README.md @@ -0,0 +1,4 @@ +# Chocolatey Publishing + +- IPFS Desktop is available at https://chocolatey.org/packages/ipfs-desktop +- Scripts present in this directory are automatically executed at CI after a new release is tagged ([#1697](https://github.com/ipfs-shipyard/ipfs-desktop/pull/1697))