|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - release-wf |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + tag: |
| 12 | + description: 'Release tag (e.g., 0.3.0)' |
| 13 | + required: true |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + release: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout source |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set version |
| 27 | + id: version |
| 28 | + run: | |
| 29 | + if [ "${{ github.event_name }}" == "release" ]; then |
| 30 | + VERSION=${{ github.event.release.tag_name }} |
| 31 | + elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
| 32 | + VERSION=${{ github.event.inputs.tag }} |
| 33 | + else |
| 34 | + # For push events, use a test version |
| 35 | + VERSION="0.3.1-test" |
| 36 | + fi |
| 37 | + # Remove 'v' prefix if present |
| 38 | + VERSION=${VERSION#v} |
| 39 | + echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 40 | +
|
| 41 | + - name: Create source archive |
| 42 | + id: archive |
| 43 | + run: | |
| 44 | + VERSION=${{ steps.version.outputs.version }} |
| 45 | + ARCHIVE_NAME="n-able-Arduino-${VERSION}.tar.gz" |
| 46 | + tar -czf "${ARCHIVE_NAME}" \ |
| 47 | + --exclude=.git \ |
| 48 | + --exclude=.github \ |
| 49 | + --exclude=.gitignore \ |
| 50 | + --exclude=node_modules \ |
| 51 | + --exclude=build \ |
| 52 | + --exclude=dist \ |
| 53 | + --transform="s,^,n-able-Arduino-${VERSION}/," \ |
| 54 | + . |
| 55 | + |
| 56 | + # Calculate checksum and size |
| 57 | + CHECKSUM=$(sha256sum "${ARCHIVE_NAME}" | cut -d ' ' -f 1) |
| 58 | + if [ -f "${ARCHIVE_NAME}" ]; then |
| 59 | + SIZE=$(stat -c%s "${ARCHIVE_NAME}") |
| 60 | + else |
| 61 | + echo "Archive not created!" |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | + |
| 65 | + echo "archive_name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT |
| 66 | + echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT |
| 67 | + echo "size=${SIZE}" >> $GITHUB_OUTPUT |
| 68 | +
|
| 69 | + - name: Checkout gh-pages |
| 70 | + uses: actions/checkout@v4 |
| 71 | + with: |
| 72 | + ref: release-test |
| 73 | + path: gh-pages |
| 74 | + |
| 75 | + - name: Update package index |
| 76 | + id: update-index |
| 77 | + env: |
| 78 | + VERSION: ${{ steps.version.outputs.version }} |
| 79 | + ARCHIVE_NAME: ${{ steps.archive.outputs.archive_name }} |
| 80 | + CHECKSUM: ${{ steps.archive.outputs.checksum }} |
| 81 | + SIZE: ${{ steps.archive.outputs.size }} |
| 82 | + run: | |
| 83 | + cd gh-pages |
| 84 | + |
| 85 | + # Create Python script to update package index |
| 86 | + cat > update_index.py << 'EOF' |
| 87 | + import json |
| 88 | + import os |
| 89 | + import sys |
| 90 | + |
| 91 | + version = os.environ.get('VERSION') |
| 92 | + archive_name = os.environ.get('ARCHIVE_NAME') |
| 93 | + checksum = os.environ.get('CHECKSUM') |
| 94 | + size = int(os.environ.get('SIZE')) |
| 95 | + |
| 96 | + # Load existing package index |
| 97 | + with open('package_n-able_boards_index.json', 'r') as f: |
| 98 | + package_data = json.load(f) |
| 99 | + |
| 100 | + # New platform entry |
| 101 | + new_platform = { |
| 102 | + "name": "Arm (Nim)BLE Boards", |
| 103 | + "architecture": "arm-ble", |
| 104 | + "version": version, |
| 105 | + "category": "Contributed", |
| 106 | + "help": { |
| 107 | + "online": "https://github.com/h2zero/n-able-Arduino/issues" |
| 108 | + }, |
| 109 | + "url": f"https://github.com/h2zero/n-able-Arduino/archive/{version}.tar.gz", |
| 110 | + "archiveFileName": archive_name, |
| 111 | + "checksum": f"SHA-256:{checksum}", |
| 112 | + "size": str(size), |
| 113 | + "boards": [ |
| 114 | + {"name": "Adafruit CLUE nRF52840"}, |
| 115 | + {"name": "Adafruit Circuit Playground Bluefruit"}, |
| 116 | + {"name": "Adafruit Feather nRF52832"}, |
| 117 | + {"name": "Adafruit Feather nRF52840 Express"}, |
| 118 | + {"name": "Adafruit Feather nRF52840 Sense"}, |
| 119 | + {"name": "Adafruit ItsyBitsy nRF52840 Express"}, |
| 120 | + {"name": "BBC micro:bit"}, |
| 121 | + {"name": "BBC micro:bit v2"}, |
| 122 | + {"name": "Bluz DK"}, |
| 123 | + {"name": "Calliope mini"}, |
| 124 | + {"name": "Ebyte E104-BT5032A-TB"}, |
| 125 | + {"name": "Ebyte E104-BT5040UA Dongle"}, |
| 126 | + {"name": "Electronut labs bluey"}, |
| 127 | + {"name": "Electronut labs hackaBLE"}, |
| 128 | + {"name": "Electronut labs hackaBLE v2"}, |
| 129 | + {"name": "Generic nRF51822"}, |
| 130 | + {"name": "Generic nRF52810"}, |
| 131 | + {"name": "Generic nRF52832"}, |
| 132 | + {"name": "Generic nRF52833"}, |
| 133 | + {"name": "Generic nRF52840"}, |
| 134 | + {"name": "ng-beacon"}, |
| 135 | + {"name": "nRF51 Dongle"}, |
| 136 | + {"name": "nRF51822 DK"}, |
| 137 | + {"name": "nRF52832 DK"}, |
| 138 | + {"name": "nRF52833 DK"}, |
| 139 | + {"name": "nRF52840 DK"}, |
| 140 | + {"name": "nRF52840 Dongle"}, |
| 141 | + {"name": "Nordic Beacon Kit"}, |
| 142 | + {"name": "OSHChip"}, |
| 143 | + {"name": "RedBear BLE Nano"}, |
| 144 | + {"name": "RedBear BLE Nano 2"}, |
| 145 | + {"name": "RedBear Blend 2"}, |
| 146 | + {"name": "RedBear nRF51822"}, |
| 147 | + {"name": "Sino:bit"}, |
| 148 | + {"name": "TinyBLE"}, |
| 149 | + {"name": "Waveshare BLE400"}, |
| 150 | + {"name": "Seeed XIAO nRF52840 Sense"} |
| 151 | + ], |
| 152 | + "toolsDependencies": [ |
| 153 | + { |
| 154 | + "packager": "h2zero", |
| 155 | + "name": "gcc-arm-none-eabi", |
| 156 | + "version": "9.3.1-1" |
| 157 | + }, |
| 158 | + { |
| 159 | + "packager": "h2zero", |
| 160 | + "name": "openocd", |
| 161 | + "version": "0.11.0-4" |
| 162 | + } |
| 163 | + ] |
| 164 | + } |
| 165 | + |
| 166 | + # Check if version already exists and update or append |
| 167 | + found = False |
| 168 | + for platform in package_data['packages'][0]['platforms']: |
| 169 | + if platform['version'] == version: |
| 170 | + # Update existing version |
| 171 | + platform.update(new_platform) |
| 172 | + found = True |
| 173 | + break |
| 174 | + |
| 175 | + if not found: |
| 176 | + # Append new version (maintaining reverse chronological order) |
| 177 | + package_data['packages'][0]['platforms'].insert(0, new_platform) |
| 178 | + |
| 179 | + # Write updated package index |
| 180 | + with open('package_n-able_boards_index.json', 'w') as f: |
| 181 | + json.dump(package_data, f, indent=2) |
| 182 | + |
| 183 | + print(f"Updated package index for version {version}") |
| 184 | + EOF |
| 185 | + |
| 186 | + python update_index.py |
| 187 | +
|
| 188 | + - name: Commit and push to gh-pages |
| 189 | + working-directory: gh-pages |
| 190 | + env: |
| 191 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 192 | + run: | |
| 193 | + git config user.name "github-actions" |
| 194 | + git config user.email "github-actions@github.com" |
| 195 | + git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git |
| 196 | + git add package_n-able_boards_index.json |
| 197 | + git commit -m "Update package index for v${{ steps.version.outputs.version }}" || echo "No changes to commit" |
| 198 | + git push origin release-test |
0 commit comments