Skip to content

Commit 555831e

Browse files
authored
Merge pull request #4 from pipe-cd/release-flow
Add release workflow
2 parents 3a23370 + 8774f40 commit 555831e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/release.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: 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+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v5
18+
with:
19+
path: piped-plugin-sdk-go
20+
fetch-depth: 0
21+
- uses: actions/checkout@v5
22+
with:
23+
repository: pipe-cd/pipecd
24+
path: pipecd
25+
fetch-depth: 0
26+
- env:
27+
INPUT_VERSION: ${{ inputs.version }}
28+
run: |
29+
cd piped-plugin-sdk-go
30+
LATEST_VERSION=$(git tag --sort=version:refname | tail -n 1)
31+
if [[ -z "$LATEST_VERSION" ]]; then
32+
LATEST_VERSION=$(git log --format="%H" --reverse -- HEAD.txt | head -n 1)
33+
fi
34+
35+
echo "Latest version: $LATEST_VERSION"
36+
echo "Input version: $INPUT_VERSION"
37+
if [[ "$LATEST_VERSION" == "$INPUT_VERSION" ]]; then
38+
echo "Version $INPUT_VERSION already exists"
39+
exit 0
40+
fi
41+
42+
LATEST_VERSION_PIPECD_COMMIT="$(git show $LATEST_VERSION:./HEAD.txt)"
43+
CURRENT_SYNCED_PIPECD_COMMIT="$(cat ./HEAD.txt)"
44+
echo "Previous version PipeCD commit: $LATEST_VERSION_PIPECD_COMMIT"
45+
echo "Next version PipeCD commit: $CURRENT_SYNCED_PIPECD_COMMIT"
46+
47+
cd ../pipecd
48+
cat > output.tmp <<EOF
49+
Release $INPUT_VERSION with changes since $LATEST_VERSION
50+
---
51+
52+
EOF
53+
git log --reverse --format="* %s" $LATEST_VERSION_PIPECD_COMMIT..$CURRENT_SYNCED_PIPECD_COMMIT -- ./pkg/plugin/sdk/ | sed -E 's/\(#([0-9]+)\)/([#\1](https:\/\/github.com\/pipe-cd\/pipecd\/pull\/\1))/g' >> output.tmp
54+
55+
cd ../piped-plugin-sdk-go
56+
gh release create --draft --target "$(git rev-parse HEAD)" --title $INPUT_VERSION --notes-file ../pipecd/output.tmp $INPUT_VERSION

0 commit comments

Comments
 (0)