From 5614f43b98a4400d5eb50cda5aade36bc862ede7 Mon Sep 17 00:00:00 2001 From: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:10:02 +0800 Subject: [PATCH] Automates version increment of winget package (#337) This automates updates of the func-e package on winget. This uses manifest generated locally, so we can control the contents easily. Signed-off-by: Adrian Cole --- .github/workflows/bump.yaml | 58 +++++++++++++++++++++++++++++++++++++ .github/workflows/msi.yaml | 23 ++++----------- 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/.github/workflows/bump.yaml b/.github/workflows/bump.yaml index 4e8c78e4..4d4012b2 100644 --- a/.github/workflows/bump.yaml +++ b/.github/workflows/bump.yaml @@ -26,6 +26,7 @@ on: env: GIT_USER_NAME: Tetrate Labs CI GIT_USER_EMAIL: 38483186+tetratelabs@users.noreply.github.com + GIT_COMMITTER: Tetrate Labs CI <38483186+tetratelabs@users.noreply.github.com> jobs: homebrew: @@ -41,3 +42,60 @@ jobs: brew bump-formula-pr --no-browse --no-audit --version "${version}" func-e env: # See env section for notes on PACKAGE_BUMP_TOKEN HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.PACKAGE_BUMP_TOKEN }} + + # This job downloads the func-e.msi from the corresponding release. It extracts properties from + # it in order to create a winget package manifest. Finally, it creates a pull request to add the + # new version. The pull request is a branch on tetratelabs/winget-pkgs so that anyone on the team + # can edit it as necessary. + msi: + name: "microsoft/winget-create" + runs-on: ubuntu-latest + steps: + - name: "Checkout func-e" + uses: actions/checkout@v2 + with: + path: func-e + + - name: "Checkout winget-pkgs" + uses: actions/checkout@v2 + with: + repository: microsoft/winget-pkgs + ref: master + path: winget-pkgs + + - name: "Write winget manifest" + run: | + tag="${GITHUB_REF#refs/tags/}" + version=${tag#v} + echo "MSI_VERSION=${version}" >> $GITHUB_ENV + cd func-e + gh release download "${tag}" -p '*windows_amd64.msi' + manifest_path=../winget-pkgs/manifests/Tetrate/func-e/${version}/Tetrate.func-e.yaml + mkdir -p $(dirname ${manifest_path}) + ./packaging/msi/winget_manifest.sh ${version} *windows_amd64.msi > ${manifest_path} + env: # See env section for notes on PACKAGE_BUMP_TOKEN + GITHUB_TOKEN: ${{ secrets.PACKAGE_BUMP_TOKEN }} + + - name: "Create winget-pkgs pull request" + uses: peter-evans/create-pull-request@v3 + id: winget-pkgs-pr + with: + path: winget-pkgs + branch: func-e-${{ env.MSI_VERSION }} + delete-branch: true + push-to-fork: tetratelabs/winget-pkgs + commit-message: "New version: Tetrate.func-e version ${{ env.MSI_VERSION }}" + committer: ${{ env.GIT_COMMITTER }} + author: ${{ env.GIT_COMMITTER }} + title: "New version: Tetrate.func-e version ${{ env.MSI_VERSION }}" + body: | + - [x] Have you signed the [Contributor License Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs)? + - [x] Have you checked that there aren't other open [pull requests](https://github.com/microsoft/winget-pkgs/pulls) for the same manifest update/change? + - [x] Have you validated your manifest locally with `winget validate --manifest `? + - [x] Have you tested your manifest locally with `winget install --manifest `? + - [x] Does your manifest conform to the [1.0 schema](https://github.com/microsoft/winget-cli/blob/master/doc/ManifestSpecv1.0.md)? + token: ${{ secrets.PACKAGE_BUMP_TOKEN }} + + - name: "Echo winget-pkgs pull request" + run: | + echo ${{ steps.winget-pkgs-pr.outputs.pull-request-url }} diff --git a/.github/workflows/msi.yaml b/.github/workflows/msi.yaml index b32ac473..83688534 100644 --- a/.github/workflows/msi.yaml +++ b/.github/workflows/msi.yaml @@ -70,18 +70,8 @@ jobs: key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('go.sum', '.bingo/*.mod') }} restore-keys: test-${{ runner.os }}-${{ env.GO_VERSION }}-go- - - name: "Build Windows Installer (MSI) and generate winget manifest" - # This intentionally defers winget manifest through GH env. - # bump.yaml will check out winget-pkgs repository and write the file there, no longer - # having access to the original files. - # - # Note: generation of winget manifest is cross-platform, but validation requires winget. - run: | - make msi - winget_manifest=$(./packaging/msi/winget_manifest.sh) - echo "WINGET_MANIFEST<> $GITHUB_ENV - echo "$winget_manifest" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV + - name: "Build Windows Installer (MSI)" + run: make msi # This only checks the installer when built on Windows as it is simpler than switching OS. # refreshenv is from choco, and lets you reload ENV variables (used here for PATH). @@ -90,12 +80,9 @@ jobs: run: call packaging\msi\verify_msi.cmd shell: cmd - # This tests writing the manifest via GHA env works. Validation requires too much setup. + # This tests the manifest via yamllint because validation via winget requires too much setup. # See https://github.com/microsoft/winget-cli/issues/754#issuecomment-896475895 - - name: "Write winget manifest" + - name: "Test winget manifest generation" run: | - manifest_path=./Tetrate.func-e.yaml - cat > "${manifest_path}" <<'EOF' - ${{ env.WINGET_MANIFEST }} - EOF + ./packaging/msi/winget_manifest.sh > Tetrate.func-e.yaml yamllint -sd '{extends: default, rules: {line-length: disable}}' Tetrate.func-e.yaml