From 15a0296cb911c3c18a878899b067f233348b1a9c Mon Sep 17 00:00:00 2001 From: "Christopher Speller (aider)" Date: Mon, 2 Dec 2024 16:12:22 +0100 Subject: [PATCH 01/10] ci: Add continuous deployment workflow for Mattermost plugin --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 975a33e9..3aa4ed28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,3 +43,30 @@ jobs: golangci-lint-version: "v1.54.2" golang-version: "1.21" secrets: inherit + + deploy: + needs: [plugin-ci, e2e] + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build plugin + run: make dist + + - name: Deploy to Mattermost instances + env: + MM_ADMIN_TOKEN: ${{ secrets.MM_ADMIN_TOKEN }} + MM_SERVER_URLS: ${{ secrets.MM_SERVER_URLS }} + run: | + PLUGIN_FILE=$(ls dist/*.tar.gz) + echo "Found plugin bundle: $PLUGIN_FILE" + + IFS=',' read -ra SERVERS <<< "$MM_SERVER_URLS" + for server in "${SERVERS[@]}"; do + echo "Deploying to $server" + curl -H "Authorization: Bearer $MM_ADMIN_TOKEN" \ + -X POST \ + -F "plugin=@$PLUGIN_FILE" \ + "$server/api/v4/plugins" + done From 785c3329814dbd963480199cb41eddbb9686440c Mon Sep 17 00:00:00 2001 From: "Christopher Speller (aider)" Date: Mon, 2 Dec 2024 16:15:03 +0100 Subject: [PATCH 02/10] ci: Enable deployment workflow on test-deploy branch for testing --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3aa4ed28..20853ed3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: deploy: needs: [plugin-ci, e2e] - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/test-deploy' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 359a866c9b7c4a8fff954c94bc0d2a10b589f568 Mon Sep 17 00:00:00 2001 From: "Christopher Speller (aider)" Date: Mon, 2 Dec 2024 16:16:52 +0100 Subject: [PATCH 03/10] feat: Support multiple tokens for Mattermost server deployments --- .github/workflows/ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20853ed3..44553ee7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,17 +56,18 @@ jobs: - name: Deploy to Mattermost instances env: - MM_ADMIN_TOKEN: ${{ secrets.MM_ADMIN_TOKEN }} - MM_SERVER_URLS: ${{ secrets.MM_SERVER_URLS }} + MM_SERVERS_CONFIG: ${{ secrets.MM_SERVERS_CONFIG }} run: | PLUGIN_FILE=$(ls dist/*.tar.gz) echo "Found plugin bundle: $PLUGIN_FILE" - IFS=',' read -ra SERVERS <<< "$MM_SERVER_URLS" - for server in "${SERVERS[@]}"; do - echo "Deploying to $server" - curl -H "Authorization: Bearer $MM_ADMIN_TOKEN" \ + echo "$MM_SERVERS_CONFIG" | jq -c '.[]' | while read -r server; do + url=$(echo "$server" | jq -r '.url') + token=$(echo "$server" | jq -r '.token') + + echo "Deploying to $url" + curl -H "Authorization: Bearer $token" \ -X POST \ -F "plugin=@$PLUGIN_FILE" \ - "$server/api/v4/plugins" + "$url/api/v4/plugins" done From e46d29134f2844928a9137a4c34fc75bb85aed44 Mon Sep 17 00:00:00 2001 From: "Christopher Speller (aider)" Date: Mon, 2 Dec 2024 16:21:50 +0100 Subject: [PATCH 04/10] feat: Add force flag for plugin deployment in CI and Makefile --- .github/workflows/ci.yml | 1 + Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44553ee7..2fd56179 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,5 +69,6 @@ jobs: curl -H "Authorization: Bearer $token" \ -X POST \ -F "plugin=@$PLUGIN_FILE" \ + -F "force=true" \ "$url/api/v4/plugins" done diff --git a/Makefile b/Makefile index 5f4b3fc9..0ca4e6ed 100644 --- a/Makefile +++ b/Makefile @@ -260,7 +260,7 @@ dist: apply server webapp bundle ## Builds and installs the plugin to a server. .PHONY: deploy deploy: dist - ./build/bin/pluginctl deploy $(PLUGIN_ID) dist/$(BUNDLE_NAME) + ./build/bin/pluginctl deploy --force $(PLUGIN_ID) dist/$(BUNDLE_NAME) ## Builds and installs the plugin to a server, updating the webapp automatically when changed. .PHONY: watch From 0c8da4234708000dce747b105f8e8eec293f4b8d Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 2 Dec 2024 16:23:08 +0100 Subject: [PATCH 05/10] unessisary --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0ca4e6ed..5f4b3fc9 100644 --- a/Makefile +++ b/Makefile @@ -260,7 +260,7 @@ dist: apply server webapp bundle ## Builds and installs the plugin to a server. .PHONY: deploy deploy: dist - ./build/bin/pluginctl deploy --force $(PLUGIN_ID) dist/$(BUNDLE_NAME) + ./build/bin/pluginctl deploy $(PLUGIN_ID) dist/$(BUNDLE_NAME) ## Builds and installs the plugin to a server, updating the webapp automatically when changed. .PHONY: watch From c5a1b41bd67625d87d07555fa564077b3a6071c8 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 2 Dec 2024 16:28:02 +0100 Subject: [PATCH 06/10] setup to test --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fd56179..893d7a57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ on: push: branches: - master + - rapid-deploy tags: - "v[0-9]+.[0-9]+.[0-9]+" pull_request: @@ -46,25 +47,25 @@ jobs: deploy: needs: [plugin-ci, e2e] - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/test-deploy' + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rapid-deploy' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - + - name: Build plugin run: make dist - + - name: Deploy to Mattermost instances env: MM_SERVERS_CONFIG: ${{ secrets.MM_SERVERS_CONFIG }} run: | PLUGIN_FILE=$(ls dist/*.tar.gz) echo "Found plugin bundle: $PLUGIN_FILE" - + echo "$MM_SERVERS_CONFIG" | jq -c '.[]' | while read -r server; do url=$(echo "$server" | jq -r '.url') token=$(echo "$server" | jq -r '.token') - + echo "Deploying to $url" curl -H "Authorization: Bearer $token" \ -X POST \ From cf7c95eb80bc445e9168aed59d4368f0bde28b9d Mon Sep 17 00:00:00 2001 From: "Christopher Speller (aider)" Date: Mon, 2 Dec 2024 17:36:25 +0100 Subject: [PATCH 07/10] feat: Add latest-master release creation and download badge --- .github/workflows/ci.yml | 33 ++++++++++++++++++++++++++++++++- README.md | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 893d7a57..50c251d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: pull_request: permissions: - contents: read + contents: write jobs: e2e: @@ -51,10 +51,41 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Build plugin run: make dist + - name: Update latest-master release + if: github.ref == 'refs/heads/master' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PLUGIN_FILE=$(ls dist/*.tar.gz) + # Get the commit message and hash + COMMIT_MSG=$(git log -1 --pretty=%B) + COMMIT_HASH=$(git rev-parse --short HEAD) + + # Delete the old release if it exists + gh release delete latest-master --yes || true + + # Delete the old tag if it exists + git tag -d latest-master || true + git push origin :refs/tags/latest-master || true + + # Create new tag and release + git tag latest-master + git push origin latest-master + + gh release create latest-master \ + --title "Latest Master Build" \ + --notes "Latest build from master branch - ${COMMIT_HASH} + + ${COMMIT_MSG}" \ + --prerelease \ + $PLUGIN_FILE + - name: Deploy to Mattermost instances env: MM_SERVERS_CONFIG: ${{ secrets.MM_SERVERS_CONFIG }} diff --git a/README.md b/README.md index 06c1c066..92155a4c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Mattermost Copilot Plugin +# Mattermost Copilot Plugin [![Download Latest Master Build](https://img.shields.io/badge/Download-Latest%20Master%20Build-blue)](https://github.com/mattermost/mattermost-plugin-ai/releases/tag/latest-master) > Mattermost plugin for local and third-party LLMs From 83ffe88227bf40a072b5f48ca5649ca2e45557c4 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 2 Dec 2024 17:45:00 +0100 Subject: [PATCH 08/10] Enable test branch --- .github/workflows/ci.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50c251d0..e6c43c0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,6 @@ jobs: run: make dist - name: Update latest-master release - if: github.ref == 'refs/heads/master' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -66,18 +65,18 @@ jobs: # Get the commit message and hash COMMIT_MSG=$(git log -1 --pretty=%B) COMMIT_HASH=$(git rev-parse --short HEAD) - + # Delete the old release if it exists gh release delete latest-master --yes || true - + # Delete the old tag if it exists git tag -d latest-master || true git push origin :refs/tags/latest-master || true - + # Create new tag and release git tag latest-master git push origin latest-master - + gh release create latest-master \ --title "Latest Master Build" \ --notes "Latest build from master branch - ${COMMIT_HASH} From ce91a0748a2bdbd4f0a249b55c0b6306b47aab96 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 2 Dec 2024 18:25:36 +0100 Subject: [PATCH 09/10] Remove test branch --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6c43c0e..7715ad18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,6 @@ on: push: branches: - master - - rapid-deploy tags: - "v[0-9]+.[0-9]+.[0-9]+" pull_request: @@ -47,7 +46,7 @@ jobs: deploy: needs: [plugin-ci, e2e] - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rapid-deploy' + if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 5b7eec387e01e4fcaa4f145bd6dfde79a3bf7a4e Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 2 Dec 2024 18:34:15 +0100 Subject: [PATCH 10/10] no need for commit message --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7715ad18..beee9aa2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,9 +78,7 @@ jobs: gh release create latest-master \ --title "Latest Master Build" \ - --notes "Latest build from master branch - ${COMMIT_HASH} - - ${COMMIT_MSG}" \ + --notes "Latest build from master branch - ${COMMIT_HASH}" \ --prerelease \ $PLUGIN_FILE