From 8f3da78e1b2e3500595a54ee27e4a69d989bd1c4 Mon Sep 17 00:00:00 2001 From: khanhtc1202 Date: Fri, 29 Aug 2025 14:17:15 +0900 Subject: [PATCH 1/3] 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/3] 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/3] 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)