|
| 1 | +name: Checkout Aptos CLI Version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Aptos CLI version (e.g., v5.1.0)' |
| 8 | + required: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + checkout_version: |
| 12 | + runs-on: windows-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v3 |
| 17 | + - name: Checkout Aptos CLI version |
| 18 | + run: | |
| 19 | + # 获取输入的版本号 |
| 20 | + $env:VERSION = "${{ github.event.inputs.version }}" |
| 21 | + |
| 22 | + # 检出 Aptos CLI 仓库 |
| 23 | + git clone https://github.com/aptos-labs/aptos-core.git |
| 24 | + cd aptos-core |
| 25 | + |
| 26 | + git fetch --tags |
| 27 | + git checkout "aptos-cli-$env:VERSION" |
| 28 | + |
| 29 | + echo "Checked out version: $env:VERSION" |
| 30 | +
|
| 31 | + - name: Download and Extract Aptos CLI release |
| 32 | + run: | |
| 33 | + $env:No_v_VERSION = "${{ github.event.inputs.version }}".Substring(1) |
| 34 | + $env:VERSION = "${{ github.event.inputs.version }}" |
| 35 | + $NAME="aptos-cli" |
| 36 | + $ZIP_NAME="$NAME-$env:No_v_VERSION-Windows-x86_64.zip" |
| 37 | + $URL = "https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-$env:VERSION/$ZIP_NAME" |
| 38 | + $DEST_DIR = "./target/cli" |
| 39 | +
|
| 40 | + cd aptos-core |
| 41 | +
|
| 42 | + New-Item -Path $DEST_DIR -ItemType Directory -Force |
| 43 | +
|
| 44 | + Invoke-WebRequest -Uri $URL -OutFile "$DEST_DIR\$ZIP_NAME" |
| 45 | + Expand-Archive -Path "$DEST_DIR\$ZIP_NAME" -DestinationPath $DEST_DIR |
| 46 | +
|
| 47 | + ls ./target/cli |
| 48 | +
|
| 49 | + Write-Host "Aptos CLI version $env:VERSION extracted to $DEST_DIR" |
| 50 | +
|
| 51 | + - name: Publish to Choco |
| 52 | + run: | |
| 53 | +
|
| 54 | + cd aptos-core |
| 55 | +
|
| 56 | + New-Item -Path chocolatey -ItemType Directory -Force |
| 57 | +
|
| 58 | + Copy-Item ..\aptos.nuspec -Destination ./chocolatey/aptos.nuspec |
| 59 | +
|
| 60 | + $NAME="aptos-cli" |
| 61 | + $CRATE_NAME="aptos" |
| 62 | + $CARGO_PATH="crates\$CRATE_NAME\Cargo.toml" |
| 63 | + $VERSION = Get-Content $CARGO_PATH | Select-String -Pattern '^\w*version = "(\d*\.\d*.\d*)"' | % {"$($_.matches.groups[1])"} |
| 64 | + $ExePath = "target\cli\$CRATE_NAME.exe" |
| 65 | + $CHOCO_API_KEY = ${{ secrets.CHOCO_API_KEY }} |
| 66 | + $apiKey = $env:CHOCO_API_KEY |
| 67 | + $ZIP_NAME="$NAME-$VERSION-Windows-x86_64.zip" |
| 68 | +
|
| 69 | + choco install checksum -y |
| 70 | +
|
| 71 | + $aptosHash = & checksum -t sha256 $ExePath |
| 72 | + |
| 73 | + Set-Location -Path "chocolatey" |
| 74 | +
|
| 75 | + @' |
| 76 | + Aptos Binary verification steps |
| 77 | + 1. Download https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-$VERSION/$ZIP_NAME |
| 78 | + 2. Extract aptos.exe |
| 79 | + 3. Verify binary: checksum.exe -t sha256 aptos.exe: $aptosHash |
| 80 | +
|
| 81 | + File 'LICENSE.txt' is obtained from: https://github.com/aptos-labs/aptos-core/blob/main/LICENSE |
| 82 | + '@ | Out-File -FilePath "VERIFICATION.txt" -Encoding utf8 -Append |
| 83 | +
|
| 84 | + Copy-Item ..\LICENSE -Destination LICENSE.txt |
| 85 | +
|
| 86 | + choco pack --version $VERSION configuration=release |
| 87 | +
|
| 88 | + ls |
| 89 | +
|
| 90 | + choco apikey --api-key $apiKey --source https://push.chocolatey.org/ |
| 91 | +
|
| 92 | + choco push aptos.$VERSION.nupkg --source https://push.chocolatey.org/ |
| 93 | +
|
| 94 | + Set-Location -Path ".." |
0 commit comments