diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..650c931 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,66 @@ +name: Build and Publish CLN Plugins + +on: + push: + tags: + - '*-plugin/v[0-9]+.[0-9]+.[0-9]+' + - '*-plugin/v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+' + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Resolve plugin and version + id: meta + run: | + TAG="$GITHUB_REF_NAME" + + echo "plugin_name=${TAG%%/*}" >> "$GITHUB_OUTPUT" + echo "version=${TAG#*/}" >> "$GITHUB_OUTPUT" + + - name: Checkout repository + uses: actions/checkout@v7 + with: + submodules: false + + - name: Validate plugin directory + env: + PLUGIN_NAME: ${{ steps.meta.outputs.plugin_name }} + run: | + if [[ ! -d "$PLUGIN_NAME" ]]; then + echo "::error::Plugin directory '$PLUGIN_NAME' not found" + exit 1 + fi + + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + with: + driver: docker-container + name: buildkit-builder + + - name: Login to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v7 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + build-args: | + PLUGIN_NAME=${{ steps.meta.outputs.plugin_name }} + tags: | + ghcr.io/blockstream/cln-plugins/${{ steps.meta.outputs.plugin_name }}:${{ steps.meta.outputs.version }} + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }}