diff --git a/.github/workflows/build.yaml b/.github/workflows/release.yaml similarity index 58% rename from .github/workflows/build.yaml rename to .github/workflows/release.yaml index b9675bb7..59660110 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/release.yaml @@ -1,12 +1,39 @@ -name: Build +name: Release on: - workflow_dispatch: + push: + tags: + - 'v*' jobs: + info: + name: Parse release info + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_version.outputs.version }} + version-without-v: ${{ steps.get_version.outputs.version-without-v }} + changelog: ${{ steps.get_changelog.outputs.changelog }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Get Version + id: get_version + uses: battila7/get-version-action@v2 + + - name: Get ChangeLog + id: get_changelog + working-directory: scripts + run: + changelog=$(python parse_changelog_of_version.py "${{ steps.get_version.outputs.version }}") + echo "changelog=${changelog}" >> $GITHUB_OUTPUT + build-jar: name: Build Jar runs-on: ubuntu-latest + needs: [ info ] steps: - uses: actions/checkout@v4 @@ -30,16 +57,17 @@ jobs: bun-version: latest - name: Build Web with Bun - run: cd web && bun install --frozen-lockfile && bun run build + working-directory: web + run: bun install --frozen-lockfile && bun run build - name: Build Boot with Gradle - run: ./gradlew :boot:bootjar -x test + run: ./gradlew -Pversion=${{ needs.info.outputs.version-without-v }} :boot:bootjar -x test - name: Upload Boot Jar uses: actions/upload-artifact@v4 with: name: boot - path: boot/build/libs/boot.jar + path: boot/build/libs/boot-${{ needs.info.outputs.version-without-v }}.jar docker-push: name: Docker Push @@ -79,9 +107,29 @@ jobs: context: boot platforms: linux/amd64,linux/arm64 push: true + build-args: | + VERSION=${{ needs.info.outputs.version-without-v }} tags: | docker.io/reajason/memshell-party:latest + docker.io/reajason/memshell-party:${{ needs.info.outputs.version-without-v }} ghcr.io/reajason/memshell-party:latest + ghcr.io/reajason/memshell-party:${{ needs.info.outputs.version-without-v }} + + create-release: + name: Create Release + needs: [ docker-push ] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - name: Release + uses: ncipollo/release-action@v1 + with: + name: ${{ needs.info.outputs.version }} + tag: ${{ needs.info.outputs.version }} + body: ${{ needs.info.outputs.changelog }} deploy-northflank: name: Deploy to Northflank diff --git a/README.md b/README.md index f1cc0d92..d01881d1 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@
一键生成常见中间件框架内存马,让内存马测试变得简单高效,打造内存马的全方位学习平台
在遍地是轮子的时代,是时候造车,带着大伙加速冲冲冲了
-[](https://github.com/ReaJason/MemShellParty/actions) -[](https://github.com/ReaJason/MemShellParty/actions) +[](https://github.com/ReaJason/MemShellParty/actions/workflows/test.yaml) +[](https://github.com/ReaJason/MemShellParty/actions/workflows/release.yaml) [](https://github.com/ReaJason/MemShellParty?tab=MIT-1-ov-file) [](https://t.me/memshell) diff --git a/scripts/parse_changelog_of_version.py b/scripts/parse_changelog_of_version.py new file mode 100644 index 00000000..c96ad804 --- /dev/null +++ b/scripts/parse_changelog_of_version.py @@ -0,0 +1,24 @@ +import argparse +import sys + +if __name__ == '__main__': + capture = False + result_lines = [] + parser = argparse.ArgumentParser(description="Extract changelog for a specific version") + parser.add_argument("version", help="The version of the changelog to extract, e.g. 'v1.0.0'") + args = parser.parse_args() + version = args.version + + with open("../CHANGELOG.md") as f: + lines = f.readlines() + for line in lines: + if line.startswith(f"## [{version}]"): + capture = True + elif capture and line.startswith("## ["): + break + elif capture: + result_lines.append(line) + if not result_lines: + print("Specified version not found.", file=sys.stderr) + sys.exit(1) + print("".join(result_lines).strip()) \ No newline at end of file