Publish to CharmHub #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to CharmHub | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| channel: | |
| description: 'CharmHub channel to publish to' | |
| required: true | |
| default: 'edge' | |
| type: choice | |
| options: | |
| - edge | |
| - beta | |
| - candidate | |
| - stable | |
| jobs: | |
| publish: | |
| name: Build and Publish Charm | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Charmcraft | |
| run: | | |
| sudo snap install charmcraft --classic | |
| - name: Get version from tag | |
| id: get_version | |
| run: | | |
| if [ "${{ github.event_name }}" = "push" ]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| else | |
| VERSION=$(git describe --tags --always) | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Update charm version in metadata | |
| run: | | |
| # Optional: Add version to metadata if needed | |
| echo "Building version ${{ steps.get_version.outputs.version }}" | |
| - name: Pack charm | |
| run: | | |
| charmcraft pack --verbose --destructive-mode | |
| - name: Upload charm artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: openclaw-charm | |
| path: openclaw_*.charm | |
| retention-days: 30 | |
| - name: Upload charm to CharmHub | |
| env: | |
| CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_TOKEN }} | |
| run: | | |
| CHARM_FILE=$(ls openclaw_*.charm | head -1) | |
| echo "Uploading $CHARM_FILE to CharmHub..." | |
| charmcraft upload $CHARM_FILE --name openclaw --format json > upload-result.json | |
| cat upload-result.json | |
| REVISION=$(jq -r '.revision' upload-result.json) | |
| echo "revision=$REVISION" >> $GITHUB_ENV | |
| echo "Uploaded as revision $REVISION" | |
| - name: Determine target channel | |
| id: channel | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| CHANNEL="${{ github.event.inputs.channel }}" | |
| elif [[ "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| # Release tag (vX.Y.Z) -> candidate channel | |
| CHANNEL="candidate" | |
| elif [[ "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+-rc ]]; then | |
| # RC tag -> beta channel | |
| CHANNEL="beta" | |
| else | |
| # All other tags -> edge channel | |
| CHANNEL="edge" | |
| fi | |
| echo "channel=$CHANNEL" >> $GITHUB_OUTPUT | |
| echo "Target channel: $CHANNEL" | |
| - name: Release to channel | |
| env: | |
| CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_TOKEN }} | |
| run: | | |
| CHANNEL="${{ steps.channel.outputs.channel }}" | |
| echo "Releasing revision ${{ env.revision }} to $CHANNEL channel..." | |
| charmcraft release openclaw \ | |
| --revision=${{ env.revision }} \ | |
| --channel=$CHANNEL | |
| echo "✓ Successfully released to $CHANNEL channel" | |
| - name: Get CharmHub status | |
| env: | |
| CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_TOKEN }} | |
| run: | | |
| echo "Current CharmHub status:" | |
| charmcraft status openclaw | |
| - name: Create GitHub Release | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: openclaw_*.charm | |
| body: | | |
| ## OpenClaw Juju Charm ${{ steps.get_version.outputs.version }} | |
| ### Installation | |
| ```bash | |
| juju deploy openclaw --channel=${{ steps.channel.outputs.channel }} | |
| ``` | |
| ### What's Included | |
| - OpenClaw Gateway service | |
| - Systemd service management | |
| - Multi-platform messaging support | |
| - Configurable AI providers | |
| - Security hardening | |
| ### Documentation | |
| - [Charm Documentation](https://fourdollars.github.io/openclaw-charm/) | |
| - [OpenClaw Docs](https://docs.openclaw.ai) | |
| - [CharmHub Page](https://charmhub.io/openclaw) | |
| ### CharmHub | |
| Published to **${{ steps.channel.outputs.channel }}** channel as revision **${{ env.revision }}** | |
| draft: false | |
| prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-alpha') || contains(github.ref, '-beta') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Notify on success | |
| if: success() | |
| run: | | |
| echo "🎉 Charm successfully published!" | |
| echo "Channel: ${{ steps.channel.outputs.channel }}" | |
| echo "Revision: ${{ env.revision }}" | |
| echo "Version: ${{ steps.get_version.outputs.version }}" | |
| echo "" | |
| echo "Install with: juju deploy openclaw --channel=${{ steps.channel.outputs.channel }}" | |
| - name: Notify on failure | |
| if: failure() | |
| run: | | |
| echo "❌ Charm publication failed" | |
| echo "Check the logs above for details" | |
| exit 1 | |
| promote-to-stable: | |
| name: Promote to Stable | |
| runs-on: ubuntu-24.04 | |
| needs: publish | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') | |
| environment: | |
| name: stable | |
| url: https://charmhub.io/openclaw | |
| steps: | |
| - name: Install Charmcraft | |
| run: | | |
| sudo snap install charmcraft --classic | |
| - name: Wait for manual approval | |
| run: | | |
| echo "⏳ Waiting for manual approval to promote to stable channel..." | |
| echo "This is the final step before production release." | |
| - name: Promote to stable | |
| env: | |
| CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_TOKEN }} | |
| run: | | |
| # Get the latest revision from candidate channel | |
| REVISION=$(charmcraft status openclaw --format json | jq -r '.[] | select(.channel == "candidate") | .revision' | head -1) | |
| echo "Promoting revision $REVISION from candidate to stable..." | |
| charmcraft release openclaw \ | |
| --revision=$REVISION \ | |
| --channel=stable | |
| echo "✓ Successfully promoted to stable channel!" | |
| - name: Verify stable release | |
| env: | |
| CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_TOKEN }} | |
| run: | | |
| echo "Verifying stable channel release..." | |
| charmcraft status openclaw | |
| echo "" | |
| echo "🎉 Charm is now available on stable channel!" | |
| echo "Install with: juju deploy openclaw" |