From c8c5283d4d262ea7bfd27bf28df3c80bfdd0f38e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 16 Nov 2026 05:38:32 +0000 Subject: [PATCH 1/2] Add GitHub Actions release workflow - Add release.yml workflow that publishes to PlatformIO Registry - Trigger on release publish and manual workflow_dispatch (dry_run option) - Verify tag matches library.json version before publishing - Run offline tests (esp32dev) and native HTTP parser tests - Pack library and attach tarball to GitHub Release - Add export.exclude to library.json to exclude test/dev files - Add RELEASING.md documenting the release process Co-authored-by: James Brown --- .github/workflows/release.yml | 111 ++++++++++++++++++++++++++++++++++ RELEASING.md | 81 +++++++++++++++++++++++++ library.json | 17 +++++- 3 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 RELEASING.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..647072c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,111 @@ +name: Release to PlatformIO Registry + +on: + release: + types: [published] + workflow_dispatch: + inputs: + dry_run: + description: 'Dry run (pack only, do not publish)' + required: false + type: boolean + default: true + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout tag + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name || github.ref }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install platformio + + - name: Verify tag matches library.json version + run: | + # Extract version from library.json + LIBRARY_VERSION=$(python -c "import json; print(json.load(open('library.json'))['version'])") + + # Get tag name (from release event or workflow_dispatch) + if [ "${{ github.event_name }}" == "release" ]; then + TAG_NAME="${{ github.event.release.tag_name }}" + else + TAG_NAME="${{ github.ref_name }}" + fi + + # Strip leading 'v' from tag + TAG_VERSION="${TAG_NAME#v}" + + echo "Library version: $LIBRARY_VERSION" + echo "Tag version: $TAG_VERSION (from tag: $TAG_NAME)" + + if [ "$LIBRARY_VERSION" != "$TAG_VERSION" ]; then + echo "❌ ERROR: Version mismatch!" + echo "Tag version '$TAG_VERSION' does not match library.json version '$LIBRARY_VERSION'" + echo "Please ensure the tag matches the version in library.json (e.g., tag v1.45 for version 1.45)" + exit 1 + fi + + echo "✅ Version verified: $LIBRARY_VERSION" + + - name: Run offline tests compile + run: | + cd tests + pio test --environment esp32dev --without-uploading --without-testing + + - name: Run native HTTP parser tests + run: | + cd tests/test_http_parser + pio test -e native + + - name: Pack library + id: pack + run: | + pio pkg pack --output Web3E-package.tar.gz + echo "package_path=Web3E-package.tar.gz" >> $GITHUB_OUTPUT + + # Show package contents + echo "đŸ“Ļ Package contents:" + tar -tzf Web3E-package.tar.gz | head -50 + + # Count total files + FILE_COUNT=$(tar -tzf Web3E-package.tar.gz | wc -l) + echo "Total files in package: $FILE_COUNT" + + - name: Publish to PlatformIO Registry + if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.dry_run == false) + env: + PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} + run: | + echo "Publishing Web3E to PlatformIO Registry..." + pio pkg publish --type library --owner alphawallet --no-interactive + + - name: Upload package artifact (dry run) + if: github.event_name == 'workflow_dispatch' && inputs.dry_run == true + uses: actions/upload-artifact@v4 + with: + name: web3e-package + path: ${{ steps.pack.outputs.package_path }} + retention-days: 30 + + - name: Attach package to GitHub Release + if: github.event_name == 'release' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ github.event.release.tag_name }} \ + ${{ steps.pack.outputs.package_path }} \ + --clobber diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..d2ecd55 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,81 @@ +# Releasing Web3E + +This document describes the process for releasing a new version of Web3E to the PlatformIO Registry. + +## Release Process + +1. **Update Version** + - Increment the `version` field in `library.json` (e.g., from `1.45` to `1.46`) + - Increment the `version` field in `library.properties` to match + - Commit the version bump to a PR and get it reviewed + +2. **Merge to Master** + - Merge the PR with the version bump into `master` + - Ensure all CI checks pass + +3. **Create GitHub Release** + - Go to [GitHub Releases](https://github.com/AlphaWallet/Web3E/releases) + - Click "Draft a new release" + - Create a new tag matching the version with a `v` prefix (e.g., `v1.46` for version `1.46`) + - Set the target to `master` + - Write release notes describing the changes + - Click "Publish release" + +4. **Automated Publishing** + - The `release.yml` GitHub Actions workflow will automatically: + - Verify the tag matches the `library.json` version + - Run offline tests to ensure the library compiles + - Run native tests (HTTP parser) + - Pack the library (excluding tests, tools, and dev files) + - Publish to the [PlatformIO Registry](https://registry.platformio.org/libraries/alphawallet/Web3E) + - Attach the packed library tarball to the GitHub Release + +5. **Verify Release** + - Check the [Actions tab](https://github.com/AlphaWallet/Web3E/actions) to ensure the workflow completed successfully + - Verify the new version appears on the [PlatformIO Registry](https://registry.platformio.org/libraries/alphawallet/Web3E) + - Check that the tarball was attached to the GitHub Release + +## Testing the Release Workflow + +You can test the release workflow without publishing by using the manual workflow dispatch: + +1. Go to [Actions → Release to PlatformIO Registry](https://github.com/AlphaWallet/Web3E/actions/workflows/release.yml) +2. Click "Run workflow" +3. Keep "Dry run" checked (default: true) +4. Select a branch/tag +5. Click "Run workflow" + +In dry run mode, the workflow will: +- Verify the version +- Run all tests +- Pack the library +- Upload the tarball as a workflow artifact (instead of publishing) + +## Version Mismatch + +If the tag version doesn't match the `library.json` version, the workflow will fail with a clear error message. For example: + +- ✅ Tag `v1.45` with `library.json` version `1.45` → Success +- ❌ Tag `v1.46` with `library.json` version `1.45` → Fail + +Always ensure the version in `library.json` is bumped and merged to master before creating the release. + +## What Gets Published + +The library package includes: +- `src/` - Source code +- `examples/` - Example projects +- `library.json` - Library metadata +- `library.properties` - Arduino library metadata + +The following are excluded from the package (see `library.json` → `export.exclude`): +- `tests/` - Test suite +- `test-consumer/` - Test consumer project +- `tools/` - Development tools +- `.github/` - GitHub workflows +- `docs/` - Documentation +- Build artifacts and caches + +## Requirements + +The workflow requires the `PLATFORMIO_AUTH_TOKEN` secret to be set in the repository. This should be configured by the repository administrator. diff --git a/library.json b/library.json index d48f7ee..e0470ff 100644 --- a/library.json +++ b/library.json @@ -32,5 +32,20 @@ ], "name": "Web3E", "version": "1.45", - "homepage": "https://www.smarttokenlabs.com/" + "homepage": "https://www.smarttokenlabs.com/", + "export": { + "exclude": [ + "tests", + "test-consumer", + "tools", + ".github", + ".git", + ".gitignore", + ".vscode", + "docs", + "*.log", + ".pio", + ".platformio" + ] + } } \ No newline at end of file From 97f46e13ce6c95786e47b04ee09282ed91da7a7b Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 16 Nov 2026 05:42:58 +0000 Subject: [PATCH 2/2] Fix release workflow issues 1. Fix dry run version check: skip tag comparison for non-tag refs 2. Add library.json vs library.properties version comparison 3. Pack tarball to /tmp to avoid including it in working directory 4. Publish the already-packed tarball instead of re-packing Co-authored-by: James Brown --- .github/workflows/release.yml | 66 +++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 647072c..8eab089 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,32 +34,51 @@ jobs: python -m pip install --upgrade pip pip install platformio - - name: Verify tag matches library.json version + - name: Verify versions run: | # Extract version from library.json - LIBRARY_VERSION=$(python -c "import json; print(json.load(open('library.json'))['version'])") + LIBRARY_JSON_VERSION=$(python -c "import json; print(json.load(open('library.json'))['version'])") - # Get tag name (from release event or workflow_dispatch) - if [ "${{ github.event_name }}" == "release" ]; then - TAG_NAME="${{ github.event.release.tag_name }}" - else - TAG_NAME="${{ github.ref_name }}" - fi - - # Strip leading 'v' from tag - TAG_VERSION="${TAG_NAME#v}" + # Extract version from library.properties + LIBRARY_PROPERTIES_VERSION=$(grep '^version=' library.properties | cut -d'=' -f2) - echo "Library version: $LIBRARY_VERSION" - echo "Tag version: $TAG_VERSION (from tag: $TAG_NAME)" + echo "library.json version: $LIBRARY_JSON_VERSION" + echo "library.properties version: $LIBRARY_PROPERTIES_VERSION" - if [ "$LIBRARY_VERSION" != "$TAG_VERSION" ]; then - echo "❌ ERROR: Version mismatch!" - echo "Tag version '$TAG_VERSION' does not match library.json version '$LIBRARY_VERSION'" - echo "Please ensure the tag matches the version in library.json (e.g., tag v1.45 for version 1.45)" + # Check library.json and library.properties match + if [ "$LIBRARY_JSON_VERSION" != "$LIBRARY_PROPERTIES_VERSION" ]; then + echo "❌ ERROR: Version mismatch between library.json and library.properties!" + echo "library.json: $LIBRARY_JSON_VERSION" + echo "library.properties: $LIBRARY_PROPERTIES_VERSION" exit 1 fi - echo "✅ Version verified: $LIBRARY_VERSION" + echo "✅ library.json and library.properties versions match: $LIBRARY_JSON_VERSION" + + # For release events or tags, verify tag matches library version + if [ "${{ github.event_name }}" == "release" ] || [ "${{ github.ref_type }}" == "tag" ]; then + if [ "${{ github.event_name }}" == "release" ]; then + TAG_NAME="${{ github.event.release.tag_name }}" + else + TAG_NAME="${{ github.ref_name }}" + fi + + # Strip leading 'v' from tag + TAG_VERSION="${TAG_NAME#v}" + + echo "Tag version: $TAG_VERSION (from tag: $TAG_NAME)" + + if [ "$LIBRARY_JSON_VERSION" != "$TAG_VERSION" ]; then + echo "❌ ERROR: Tag version mismatch!" + echo "Tag version '$TAG_VERSION' does not match library version '$LIBRARY_JSON_VERSION'" + echo "Please ensure the tag matches the version in library.json (e.g., tag v1.45 for version 1.45)" + exit 1 + fi + + echo "✅ Tag version verified: $TAG_VERSION" + else + echo "â„šī¸ Running on non-tag ref '${{ github.ref_name }}', skipping tag version check" + fi - name: Run offline tests compile run: | @@ -74,15 +93,16 @@ jobs: - name: Pack library id: pack run: | - pio pkg pack --output Web3E-package.tar.gz - echo "package_path=Web3E-package.tar.gz" >> $GITHUB_OUTPUT + # Pack to /tmp to avoid including the tarball in the working directory + pio pkg pack --output /tmp/Web3E-package.tar.gz + echo "package_path=/tmp/Web3E-package.tar.gz" >> $GITHUB_OUTPUT # Show package contents echo "đŸ“Ļ Package contents:" - tar -tzf Web3E-package.tar.gz | head -50 + tar -tzf /tmp/Web3E-package.tar.gz | head -50 # Count total files - FILE_COUNT=$(tar -tzf Web3E-package.tar.gz | wc -l) + FILE_COUNT=$(tar -tzf /tmp/Web3E-package.tar.gz | wc -l) echo "Total files in package: $FILE_COUNT" - name: Publish to PlatformIO Registry @@ -91,7 +111,7 @@ jobs: PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} run: | echo "Publishing Web3E to PlatformIO Registry..." - pio pkg publish --type library --owner alphawallet --no-interactive + pio pkg publish ${{ steps.pack.outputs.package_path }} --type library --owner alphawallet --no-interactive - name: Upload package artifact (dry run) if: github.event_name == 'workflow_dispatch' && inputs.dry_run == true