From 8f3da78e1b2e3500595a54ee27e4a69d989bd1c4 Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Fri, 29 Aug 2025 14:17:15 +0900 Subject: [PATCH 1/6] Add release plugin workflow Signed-off-by: khanhtc1202 --- .github/workflows/plugin_release.yaml | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/plugin_release.yaml diff --git a/.github/workflows/plugin_release.yaml b/.github/workflows/plugin_release.yaml new file mode 100644 index 0000000000..42f967edc7 --- /dev/null +++ b/.github/workflows/plugin_release.yaml @@ -0,0 +1,52 @@ +name: plugin_release + +on: + workflow_dispatch: + inputs: + version: + description: "Version to release (e.g. v0.1.0)" + required: true + path: + description: "Plugin source path (e.g. pkg/app/pipedv1/plugin/kubernetes)" + required: true + type: string + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + repository: pipe-cd/pipecd + fetch-depth: 0 + - env: + INPUT_VERSION: ${{ inputs.version }} + INPUT_PATH: ${{ inputs.path }} + GH_TOKEN: ${{ github.token }} + run: | + LATEST_VERSION=$(git tag -l '${{ inputs.path }}/v*' | sort -t/ -k2 -V | tail -n1) + + if [[ -z "$LATEST_VERSION" ]]; then + LATEST_VERSION=$(git log --format="%H" --reverse -- ./${{ inputs.path }}/ | head -n 1) + fi + + echo "Latest version: $LATEST_VERSION" + echo "Input version: $INPUT_VERSION" + if [[ "$LATEST_VERSION" == "$INPUT_VERSION" ]]; then + echo "Version $INPUT_VERSION already exists" + exit 0 + fi + + PLUGIN_NAME=$(basename $INPUT_PATH) + + cat > output.tmp <> output.tmp + + gh release create --draft --target "$(git rev-parse HEAD)" --title "$PLUGIN_NAME $INPUT_VERSION" --notes-file output.tmp $INPUT_PATH/$INPUT_VERSION From f32d316fb269a7c646aee568b02f38b208ee263c Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Fri, 29 Aug 2025 14:30:18 +0900 Subject: [PATCH 2/6] Add publish binary step Signed-off-by: khanhtc1202 --- .github/workflows/plugin_release.yaml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugin_release.yaml b/.github/workflows/plugin_release.yaml index 42f967edc7..7869f53d61 100644 --- a/.github/workflows/plugin_release.yaml +++ b/.github/workflows/plugin_release.yaml @@ -22,6 +22,18 @@ jobs: with: repository: pipe-cd/pipecd fetch-depth: 0 + - uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + cache: true + - name: Determine Plugin Info + run: echo "PLUGIN_NAME=$(basename $INPUT_PATH)" >> $GITHUB_ENV + - name: Build binary artifacts + run: | + make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=linux BUILD_ARCH=amd64 BIN_SUFFIX=_${{ inputs.version }}_linux_amd64 + make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=linux BUILD_ARCH=arm64 BIN_SUFFIX=_${{ inputs.version }}_linux_arm64 + make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=darwin BUILD_ARCH=amd64 BIN_SUFFIX=_${{ inputs.version }}_darwin_amd64 + make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=darwin BUILD_ARCH=arm64 BIN_SUFFIX=_${{ inputs.version }}_darwin_arm64 - env: INPUT_VERSION: ${{ inputs.version }} INPUT_PATH: ${{ inputs.path }} @@ -40,8 +52,6 @@ jobs: exit 0 fi - PLUGIN_NAME=$(basename $INPUT_PATH) - cat > output.tmp <> output.tmp gh release create --draft --target "$(git rev-parse HEAD)" --title "$PLUGIN_NAME $INPUT_VERSION" --notes-file output.tmp $INPUT_PATH/$INPUT_VERSION + - name: Publish binary artifacts + uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda #v2.2.1 + with: + tag_name: ${{ inputs.path }}/${{ inputs.version }} + files: | + ./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_linux_amd64 + ./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_linux_arm64 + ./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_darwin_amd64 + ./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_darwin_arm64 From 7e720dfc5e8daf7b28290306b2970dd995f9072c Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Fri, 29 Aug 2025 14:38:55 +0900 Subject: [PATCH 3/6] Update get version command Signed-off-by: khanhtc1202 --- .github/workflows/plugin_release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugin_release.yaml b/.github/workflows/plugin_release.yaml index 7869f53d61..3548196d97 100644 --- a/.github/workflows/plugin_release.yaml +++ b/.github/workflows/plugin_release.yaml @@ -39,7 +39,7 @@ jobs: INPUT_PATH: ${{ inputs.path }} GH_TOKEN: ${{ github.token }} run: | - LATEST_VERSION=$(git tag -l '${{ inputs.path }}/v*' | sort -t/ -k2 -V | tail -n1) + LATEST_VERSION=$(git tag -l '${{ inputs.path }}/v*' | awk -F/ '{print $NF, $0}' | sort -k1 -V | tail -n1 | cut -d' ' -f2-) if [[ -z "$LATEST_VERSION" ]]; then LATEST_VERSION=$(git log --format="%H" --reverse -- ./${{ inputs.path }}/ | head -n 1) From 501a062604d21c401d5649270533d3a1e7c4a41d Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Fri, 29 Aug 2025 14:53:51 +0900 Subject: [PATCH 4/6] Update workflow Signed-off-by: khanhtc1202 --- .github/workflows/plugin_release.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugin_release.yaml b/.github/workflows/plugin_release.yaml index 3548196d97..6a8cc2a873 100644 --- a/.github/workflows/plugin_release.yaml +++ b/.github/workflows/plugin_release.yaml @@ -27,7 +27,7 @@ jobs: go-version: ${{ env.GO_VERSION }} cache: true - name: Determine Plugin Info - run: echo "PLUGIN_NAME=$(basename $INPUT_PATH)" >> $GITHUB_ENV + run: echo "PLUGIN_NAME=$(basename ${{ inputs.path }})" >> $GITHUB_ENV - name: Build binary artifacts run: | make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=linux BUILD_ARCH=amd64 BIN_SUFFIX=_${{ inputs.version }}_linux_amd64 @@ -59,11 +59,15 @@ jobs: EOF git log --reverse --format="* %s" $LATEST_VERSION..HEAD -- $INPUT_PATH | sed -E 's/\(#([0-9]+)\)/([#\1](https:\/\/github.com\/pipe-cd\/pipecd\/pull\/\1))/g' >> output.tmp - gh release create --draft --target "$(git rev-parse HEAD)" --title "$PLUGIN_NAME $INPUT_VERSION" --notes-file output.tmp $INPUT_PATH/$INPUT_VERSION + # gh release create --draft --target "$(git rev-parse HEAD)" --title "$PLUGIN_NAME $INPUT_VERSION" --notes-file output.tmp $INPUT_PATH/$INPUT_VERSION - name: Publish binary artifacts uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda #v2.2.1 with: tag_name: ${{ inputs.path }}/${{ inputs.version }} + body_path: output.tmp + name: ${{ env.PLUGIN_NAME }} ${{ inputs.version }} + target_commitish: ${{ github.sha }} + draft: true files: | ./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_linux_amd64 ./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_linux_arm64 From e15ef15019e1a9dbbe3ce3f4c9ace7e3cd48539b Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Fri, 29 Aug 2025 15:04:12 +0900 Subject: [PATCH 5/6] Remove unused code Signed-off-by: khanhtc1202 --- .github/workflows/plugin_release.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/plugin_release.yaml b/.github/workflows/plugin_release.yaml index 6a8cc2a873..91159f2ffa 100644 --- a/.github/workflows/plugin_release.yaml +++ b/.github/workflows/plugin_release.yaml @@ -58,8 +58,6 @@ jobs: EOF git log --reverse --format="* %s" $LATEST_VERSION..HEAD -- $INPUT_PATH | sed -E 's/\(#([0-9]+)\)/([#\1](https:\/\/github.com\/pipe-cd\/pipecd\/pull\/\1))/g' >> output.tmp - - # gh release create --draft --target "$(git rev-parse HEAD)" --title "$PLUGIN_NAME $INPUT_VERSION" --notes-file output.tmp $INPUT_PATH/$INPUT_VERSION - name: Publish binary artifacts uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda #v2.2.1 with: From db622822badf567cbdac1a0c95ed715158c8240c Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Fri, 29 Aug 2025 15:05:29 +0900 Subject: [PATCH 6/6] Add flag to release step Signed-off-by: khanhtc1202 --- .github/workflows/plugin_release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/plugin_release.yaml b/.github/workflows/plugin_release.yaml index 91159f2ffa..d5889adfcd 100644 --- a/.github/workflows/plugin_release.yaml +++ b/.github/workflows/plugin_release.yaml @@ -66,6 +66,7 @@ jobs: name: ${{ env.PLUGIN_NAME }} ${{ inputs.version }} target_commitish: ${{ github.sha }} draft: true + make_latest: "false" files: | ./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_linux_amd64 ./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_linux_arm64