diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b047a3..91fe320 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,22 +53,10 @@ jobs: DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} GITHUB_ACTOR: ${{ github.actor }} GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }} + WEBSOCKET_API_PORTAINER_WEBHOOK_URL: ${{ secrets.WEBSOCKET_API_PORTAINER_WEBHOOK_URL }} + DISCORD_BOT_PORTAINER_WEBHOOK_URL: ${{ secrets.DISCORD_BOT_PORTAINER_WEBHOOK_URL }} run: bunx multi-semantic-release - - name: Set Portainer stack webhook URL based on branch - run: | - if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then - PORTAINER_WEBHOOK_URL=${{ secrets.PORTAINER_WEBHOOK_MAIN_URL }} - else - PORTAINER_WEBHOOK_URL=${{ secrets.PORTAINER_WEBHOOK_DEV_URL }} - fi - echo "PORTAINER_WEBHOOK_URL=$PORTAINER_WEBHOOK_URL" >> $GITHUB_ENV - - - name: Trigger Portainer stack update - uses: newarifrh/portainer-service-webhook@v1 - with: - webhook_url: ${{ env.PORTAINER_WEBHOOK_URL }} - - name: Purge outdated images uses: snok/container-retention-policy@v3.0.0 with: diff --git a/.releaserc b/.releaserc index 42d6f0c..2d80a81 100644 --- a/.releaserc +++ b/.releaserc @@ -11,7 +11,7 @@ "@semantic-release/commit-analyzer", { "releaseRules": [ - { "type": "build", "scope": "Needs bump", "release": "patch"} + { "type": "build", "scope": "Needs bump", "release": "patch" } ] } ], @@ -48,7 +48,8 @@ } ], "clearWorkspace": true - } + }, + true ] ] } \ No newline at end of file diff --git a/apis/websocket/.releaserc b/apis/websocket/.releaserc deleted file mode 100644 index 913e5d4..0000000 --- a/apis/websocket/.releaserc +++ /dev/null @@ -1,21 +0,0 @@ -{ - "plugins": [ - [ - "@codedependant/semantic-release-docker", - { - "dockerImage": "revanced-bot-websocket-api", - "dockerRegistry": "ghcr.io", - "dockerProject": "revanced", - "dockerContext": "../..", - "dockerPlatform": [ - "linux/amd64", - "linux/arm64" - ], - "dockerArgs": { - "GITHUB_ACTOR": null, - "GITHUB_TOKEN": null - } - } - ] - ] -} \ No newline at end of file diff --git a/apis/websocket/.releaserc.js b/apis/websocket/.releaserc.js new file mode 100644 index 0000000..811889d --- /dev/null +++ b/apis/websocket/.releaserc.js @@ -0,0 +1,31 @@ +import { $ } from 'execa' + +const branch = (await $`git rev-parse --abbrev-ref HEAD`).stdout.trim() + +export default { + plugins: + branch === 'main' + ? [ + [ + '@codedependant/semantic-release-docker', + { + dockerImage: 'revanced-bot-websocket-api', + dockerRegistry: 'ghcr.io', + dockerProject: 'revanced', + dockerContext: '../..', + dockerPlatform: ['linux/amd64', 'linux/arm64'], + dockerArgs: { + GITHUB_ACTOR: null, + GITHUB_TOKEN: null, + }, + }, + ], + [ + '@semantic-release/exec', + { + publishCmd: 'bun run scripts/trigger-portainer-webhook.ts', + }, + ], + ] + : [], +} diff --git a/apis/websocket/scripts/trigger-portainer-webhook.ts b/apis/websocket/scripts/trigger-portainer-webhook.ts new file mode 100644 index 0000000..a8d89bb --- /dev/null +++ b/apis/websocket/scripts/trigger-portainer-webhook.ts @@ -0,0 +1,4 @@ +import { $ } from 'bun' + +const URLEnvironmentVariableName = 'WEBSOCKET_API_PORTAINER_WEBHOOK_URL' +await $`INPUT_WEBHOOK_URL=${process.env[URLEnvironmentVariableName]} bun run ../../node_modules/portainer-service-webhook/dist` diff --git a/bots/discord/.releaserc b/bots/discord/.releaserc deleted file mode 100644 index 898cfd2..0000000 --- a/bots/discord/.releaserc +++ /dev/null @@ -1,21 +0,0 @@ -{ - "plugins": [ - [ - "@codedependant/semantic-release-docker", - { - "dockerImage": "revanced-bot-discord", - "dockerRegistry": "ghcr.io", - "dockerProject": "revanced", - "dockerContext": "../..", - "dockerPlatform": [ - "linux/amd64", - "linux/arm64" - ], - "dockerArgs": { - "GITHUB_ACTOR": null, - "GITHUB_TOKEN": null - } - } - ] - ] -} \ No newline at end of file diff --git a/bots/discord/.releaserc.js b/bots/discord/.releaserc.js new file mode 100644 index 0000000..06f1fec --- /dev/null +++ b/bots/discord/.releaserc.js @@ -0,0 +1,31 @@ +import { $ } from 'execa' + +const branch = (await $`git rev-parse --abbrev-ref HEAD`).stdout.trim() + +export default { + plugins: + branch === 'main' + ? [ + [ + '@codedependant/semantic-release-docker', + { + dockerImage: 'revanced-bot-discord', + dockerRegistry: 'ghcr.io', + dockerProject: 'revanced', + dockerContext: '../..', + dockerPlatform: ['linux/amd64', 'linux/arm64'], + dockerArgs: { + GITHUB_ACTOR: null, + GITHUB_TOKEN: null, + }, + }, + ], + [ + '@semantic-release/exec', + { + publishCmd: 'bun run scripts/trigger-portainer-webhook.ts', + }, + ], + ] + : [], +} diff --git a/bots/discord/scripts/trigger-portainer-webhook.ts b/bots/discord/scripts/trigger-portainer-webhook.ts new file mode 100644 index 0000000..c2f3855 --- /dev/null +++ b/bots/discord/scripts/trigger-portainer-webhook.ts @@ -0,0 +1,4 @@ +import { $ } from 'bun' + +const URLEnvironmentVariableName = 'DISCORD_BOT_PORTAINER_WEBHOOK_URL' +await $`INPUT_WEBHOOK_URL=${process.env[URLEnvironmentVariableName]} bun run ../../node_modules/portainer-service-webhook/dist` diff --git a/package.json b/package.json index fff9d77..903a0f1 100644 --- a/package.json +++ b/package.json @@ -34,10 +34,9 @@ "@codedependant/semantic-release-docker": "^5.0.3", "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", - "@revanced/bot-api": "workspace:*", - "@revanced/bot-shared": "workspace:*", "@saithodev/semantic-release-backmerge": "^4.0.1", "@semantic-release/changelog": "^6.0.3", + "@semantic-release/exec": "^6.0.3", "@semantic-release/git": "^10.0.1", "@semantic-release/github": "^10.1.0", "@tsconfig/strictest": "^2.0.5", diff --git a/patches/@anolilab%2Fmulti-semantic-release@1.1.3.patch b/patches/@anolilab%2Fmulti-semantic-release@1.1.3.patch index 24584e7..dd96e2a 100644 --- a/patches/@anolilab%2Fmulti-semantic-release@1.1.3.patch +++ b/patches/@anolilab%2Fmulti-semantic-release@1.1.3.patch @@ -1,14 +1,16 @@ diff --git a/lib/multi-semantic-release.js b/lib/multi-semantic-release.js -index 1247e618244dc35f6d60d1e484fbd1a84e504b2a..4b6f1bb5aae5219db2069412f56094af0e33a664 100644 +index 1247e618244dc35f6d60d1e484fbd1a84e504b2a..fc8dbf1c418351f2c25698e3fc3fab478693f125 100644 --- a/lib/multi-semantic-release.js +++ b/lib/multi-semantic-release.js -@@ -114,6 +114,9 @@ async function releasePackage(package_, createInlinePlugin, multiContext, flags) +@@ -114,6 +114,11 @@ async function releasePackage(package_, createInlinePlugin, multiContext, flags) options.ci = flags.ci === undefined ? options.ci : flags.ci; options.branches = flags.branches ? castArray(flags.branches) : options.branches; + // Patching so plugins from globalOptions are also inherited. ++ // If the third element in the array is set to true, the plugin will not be inherited. + options.plugins = [...(multiContext.globalOptions.plugins || []), ...(options.plugins || [])] ++ .filter(plugin => Array.isArray(plugin) ? !plugin[2] : true) + // This options are needed for plugins that do not rely on `pluginOptions` and extract them independently. options._pkgOptions = packageOptions; - +