Skip to content

Commit

Permalink
chore: add winget cd support (#551)
Browse files Browse the repository at this point in the history
* chore: add winget cd support
  • Loading branch information
neilcampbell authored Aug 2, 2024
1 parent 3e2d017 commit cc4baa3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 35 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.release_version != '' && format('v{0}', inputs.release_version) || '' }}
fetch-depth: 1

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ jobs:

cd-publish-release-packages:
name: Release binaries via distribution channels
needs: build-and-upload-binaries
needs:
- release
- build-and-upload-binaries
if: ${{ github.ref_name == 'main' && inputs.production_release == 'true' }} # Might want to adjust this to publish (pre-release) on merge as well.
uses: ./.github/workflows/publish-release-packages.yaml
with:
artifactName: algokit-cli
release_version: ${{ needs.release.outputs.release_version }}
secrets: inherit
38 changes: 15 additions & 23 deletions .github/workflows/publish-release-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
required: true
type: string
description: "The github artifact holding the wheel file which will be published"
release_version:
required: true
type: string
description: "The release version that will be published (e.g. 0.1.0)"
do_brew:
required: false
default: true
Expand All @@ -29,10 +33,10 @@ on:
description: "Publish to Winget repository"
workflow_dispatch:
inputs:
release:
release_version:
required: true
type: string
description: "The existing github release which will be published (e.g. v0.1.0)"
description: "The release version that will be published (e.g. 0.1.0). Note this is not the tag version."
do_brew:
required: false
default: true
Expand Down Expand Up @@ -65,7 +69,7 @@ jobs:
# Download either via release or provided artifact
- name: Download release
if: ${{ github.event_name == 'workflow_dispatch' }}
run: gh release download ${{ inputs.release }} --pattern "*.whl" --dir dist
run: gh release download v${{ inputs.release_version }} --pattern "*.whl" --dir dist
env:
GH_TOKEN: ${{ github.token }}

Expand Down Expand Up @@ -94,7 +98,7 @@ jobs:
# Download either via release or provided artifact
- name: Download release
if: ${{ github.event_name == 'workflow_dispatch' }}
run: gh release download ${{ inputs.release }} --pattern "*.whl" --dir dist
run: gh release download v${{ inputs.release_version }} --pattern "*.whl" --dir dist
env:
GH_TOKEN: ${{ github.token }}

Expand Down Expand Up @@ -128,15 +132,17 @@ jobs:
runs-on: windows-latest
if: ${{ inputs.do_winget }}
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Publish to winget
shell: pwsh
env:
WINGET_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
run: |
echo 'Publishing to winget'
# The below can be uncommented after we've manually created the first release on winget
# & .\scripts\winget\update-package.ps1 `
# -releaseVersionTag '${{ inputs.release }}'
& .\scripts\winget\update-package.ps1 `
-releaseVersion '${{ inputs.release_version }}'
publish-snap:
runs-on: ubuntu-latest
Expand All @@ -145,32 +151,18 @@ jobs:
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set release version
shell: bash
continue-on-error: true
run: |
if [ -z "${{ inputs.release }}" ]; then
echo "RELEASE_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
git describe --tags $(git rev-list --tags --max-count=1)
else
echo "RELEASE_VERSION=${{ inputs.release }}" >> $GITHUB_ENV
fi

- name: Download binary artifact from release
if: ${{ env.RELEASE_VERSION != '' || (github.event_name == 'workflow_dispatch' && inputs.release != '') }}
run: |
gh release download ${{ env.RELEASE_VERSION || inputs.release }} --pattern "*-snap.tar.gz" --dir dist
gh release download v${{ inputs.release_version }} --pattern "*-snap.tar.gz" --dir dist
BINARY_PATH=$(ls dist/*-snap.tar.gz)
echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ github.token }}

- name: Generate snapcraft.yaml
run: |
./scripts/snap/create-snapcraft-yaml.sh ${{ github.workspace }} ${{ env.RELEASE_VERSION }} ${{ env.BINARY_PATH }} "stable"
./scripts/snap/create-snapcraft-yaml.sh ${{ github.workspace }} ${{ inputs.release_version }} ${{ env.BINARY_PATH }} "stable"
- name: Upload snapcraft.yaml as reference artifact
uses: actions/upload-artifact@v2
Expand Down
9 changes: 3 additions & 6 deletions scripts/snap/create-snapcraft-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,26 @@ set -e

# Check if the correct number of arguments are passed
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <destination_directory> <release_tag> <artifact_path> <grade>"
echo "Usage: $0 <destination_directory> <release_version> <artifact_path> <grade>"
exit 1
fi

# Assign arguments to variables
DESTINATION_DIR="$1"
RELEASE_TAG="$2"
RELEASE_VERSION="$2"
ARTIFACT_PATH="$3"
GRADE="$4"

# Ensure the destination directory exists
mkdir -p "${DESTINATION_DIR}/snap"

# Extract version from RELEASE_TAG, assuming it's in the format "vX.Y.Z"
VERSION="${RELEASE_TAG#v}"

# Use the provided ARTIFACT_PATH
SOURCE="$ARTIFACT_PATH"

# Create the snapcraft.yaml file
cat > "${DESTINATION_DIR}/snap/snapcraft.yaml" <<EOF
name: algokit
version: "$VERSION"
version: "$RELEASE_VERSION"
summary: The AlgoKit CLI is the one-stop shop tool for developers building on Algorand
description: |
AlgoKit gets developers of all levels up and running with a familiar,
Expand Down
7 changes: 3 additions & 4 deletions scripts/winget/update-package.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Param(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[String]
$releaseVersionTag
$releaseVersion
)

Function ThrowOnNonZeroExit {
Expand All @@ -12,9 +12,8 @@ Function ThrowOnNonZeroExit {
}

$wingetPackage = 'AlgorandFoundation.AlgoKit'
$release = Invoke-RestMethod -uri "https://api.github.com/repos/algorandfoundation/algokit-cli/releases/tags/$releaseVersionTag"
$release = Invoke-RestMethod -uri "https://api.github.com/repos/algorandfoundation/algokit-cli/releases/tags/v$releaseVersion"
$installerUrl = $release | Select -ExpandProperty assets -First 1 | Where-Object -Property name -match '-windows_x64-winget\.msix$' | Select -ExpandProperty browser_download_url
$releaseVersion = $releaseVersionTag.Trim("v")

$wingetDir = New-Item -Force -ItemType Directory -Path .\build\winget
$wingetExecutable = "$wingetDir\wingetcreate.exe"
Expand Down

1 comment on commit cc4baa3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit
   __init__.py15753%6–13, 17–24, 32–34
   __main__.py440%1–7
src/algokit/cli
   __init__.py47394%31–34
   codespace.py50982%28, 114, 137, 150–155
   completions.py108992%63–64, 83, 93–99
   dispenser.py121199%77
   doctor.py53394%146–148
   explore.py631576%35–40, 42–47, 85–92, 113
   generate.py70396%76–77, 155
   goal.py47198%79
   init.py3112492%497–498, 503–504, 507, 528, 531–533, 544, 548, 606, 632, 661, 694, 703–705, 708–713, 726, 745, 757–758
   localnet.py1523279%65, 86–113, 133–137, 170, 182, 197–207, 220, 271, 292–293
   task.py34391%25–28
src/algokit/cli/project
   bootstrap.py32197%33
   deploy.py992080%47, 49, 101, 124, 146–148, 227, 234, 248–256, 259–268
   link.py891682%60, 65–66, 101–105, 115–120, 148–149, 218–219, 223
   list.py33585%21–23, 51–56
   run.py46393%38, 71, 160
src/algokit/cli/tasks
   analyze.py81199%81
   assets.py821384%65–66, 72, 74–75, 105, 119, 125–126, 132, 134, 136–137
   ipfs.py51884%52, 80, 92, 94–95, 105–107
   mint.py66494%48, 70, 91, 250
   send_transaction.py651085%52–53, 57, 89, 158, 170–174
   sign_transaction.py59886%21, 28–30, 71–72, 109, 123
   transfer.py39392%26, 90, 117
   utils.py994555%26–34, 40–43, 75–76, 100–101, 125–133, 152–162, 209, 258–259, 279–290, 297–299
   vanity_address.py561082%41, 45–48, 112, 114, 121–123
   wallet.py79495%21, 66, 136, 162
src/algokit/core
   codespace.py1756861%34–37, 41–44, 48–71, 111–112, 125–133, 191, 200–202, 210, 216–217, 229–236, 251–298, 311–313, 338–344, 348, 395
   conf.py57984%12, 24, 28, 36, 38, 73–75, 80
   dispenser.py2022687%91, 123–124, 141–149, 191–192, 198–200, 218–219, 259–260, 318, 332–334, 345–346, 356, 369, 384
   doctor.py65789%67–69, 92–94, 134
   generate.py50394%44, 85, 103
   goal.py65494%21, 36–37, 47
   init.py671085%53, 57–62, 70, 81, 88, 108–109
   log_handlers.py68790%50–51, 63, 112–116, 125
   proc.py45198%99
   sandbox.py2632391%32, 89–92, 97, 101–103, 153, 201–208, 219, 590, 606, 631, 639
   typed_client_generation.py1702088%62–64, 103–108, 132, 135–138, 156, 159–162, 229, 232–235
   utils.py1504073%50–51, 57–69, 125–131, 155, 158, 164–177, 206–208, 237–240, 262
src/algokit/core/compilers
   python.py28582%19–20, 25, 49–50
src/algokit/core/config_commands
   container_engine.py412149%24, 29–31, 47–76
   version_prompt.py921485%37–38, 68, 87–90, 108, 118–125, 148
src/algokit/core/project
   __init__.py53394%50, 86, 145
   bootstrap.py120893%47, 126–127, 149, 176, 207–209
   deploy.py69987%108–111, 120–122, 126, 131
   run.py1251588%83, 88, 97–98, 133–134, 138–139, 143, 147, 261–269, 284
src/algokit/core/tasks
   analyze.py93397%105–112, 187
   ipfs.py63789%58–64, 140, 144, 146, 152
   nfd.py491373%25, 31, 34–41, 70–72, 99–101
   vanity_address.py903462%49–50, 54, 59–75, 92–108, 128–131
   wallet.py71593%37, 129, 155–157
src/algokit/core/tasks/mint
   mint.py781087%123–133, 187
   models.py901188%50, 52, 57, 71–74, 85–88
TOTAL466164186% 

Tests Skipped Failures Errors Time
489 0 💤 0 ❌ 0 🔥 25.408s ⏱️

Please sign in to comment.