Skip to content

Commit 8a9bac1

Browse files
authored
Add release plugin workflow (#6190)
* Add release plugin workflow Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com> * Add publish binary step Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com> * Update get version command Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com> --------- Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com>
1 parent 69f5ab1 commit 8a9bac1

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: plugin_release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to release (e.g. v0.1.0)"
8+
required: true
9+
path:
10+
description: "Plugin source path (e.g. pkg/app/pipedv1/plugin/kubernetes)"
11+
required: true
12+
type: string
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
release:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v5
22+
with:
23+
repository: pipe-cd/pipecd
24+
fetch-depth: 0
25+
- uses: actions/setup-go@v3
26+
with:
27+
go-version: ${{ env.GO_VERSION }}
28+
cache: true
29+
- name: Determine Plugin Info
30+
run: echo "PLUGIN_NAME=$(basename $INPUT_PATH)" >> $GITHUB_ENV
31+
- name: Build binary artifacts
32+
run: |
33+
make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=linux BUILD_ARCH=amd64 BIN_SUFFIX=_${{ inputs.version }}_linux_amd64
34+
make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=linux BUILD_ARCH=arm64 BIN_SUFFIX=_${{ inputs.version }}_linux_arm64
35+
make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=darwin BUILD_ARCH=amd64 BIN_SUFFIX=_${{ inputs.version }}_darwin_amd64
36+
make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=darwin BUILD_ARCH=arm64 BIN_SUFFIX=_${{ inputs.version }}_darwin_arm64
37+
- env:
38+
INPUT_VERSION: ${{ inputs.version }}
39+
INPUT_PATH: ${{ inputs.path }}
40+
GH_TOKEN: ${{ github.token }}
41+
run: |
42+
LATEST_VERSION=$(git tag -l '${{ inputs.path }}/v*' | awk -F/ '{print $NF, $0}' | sort -k1 -V | tail -n1 | cut -d' ' -f2-)
43+
44+
if [[ -z "$LATEST_VERSION" ]]; then
45+
LATEST_VERSION=$(git log --format="%H" --reverse -- ./${{ inputs.path }}/ | head -n 1)
46+
fi
47+
48+
echo "Latest version: $LATEST_VERSION"
49+
echo "Input version: $INPUT_VERSION"
50+
if [[ "$LATEST_VERSION" == "$INPUT_VERSION" ]]; then
51+
echo "Version $INPUT_VERSION already exists"
52+
exit 0
53+
fi
54+
55+
cat > output.tmp <<EOF
56+
Plugin $PLUGIN_NAME Release $INPUT_VERSION with changes since $LATEST_VERSION
57+
---
58+
59+
EOF
60+
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
61+
62+
gh release create --draft --target "$(git rev-parse HEAD)" --title "$PLUGIN_NAME $INPUT_VERSION" --notes-file output.tmp $INPUT_PATH/$INPUT_VERSION
63+
- name: Publish binary artifacts
64+
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda #v2.2.1
65+
with:
66+
tag_name: ${{ inputs.path }}/${{ inputs.version }}
67+
files: |
68+
./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_linux_amd64
69+
./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_linux_arm64
70+
./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_darwin_amd64
71+
./.artifacts/plugins/${{ env.PLUGIN_NAME }}_${{ inputs.version }}_darwin_arm64

0 commit comments

Comments
 (0)