From dc248a1306934c3881fd2f067ceac5c53068bb22 Mon Sep 17 00:00:00 2001 From: Yue Yang Date: Wed, 27 Dec 2023 14:10:31 +0800 Subject: [PATCH] refactor: release workflow (#20) Signed-off-by: Yue Yang --- .editorconfig | 12 ++++++ .github/workflows/release.yml | 61 ++++++++++++++++++++++++++++ .github/workflows/release_latest.yml | 57 -------------------------- .github/workflows/release_tag.yml | 57 -------------------------- .github/workflows/test.yml | 8 ++-- 5 files changed, 77 insertions(+), 118 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/release_latest.yml delete mode 100644 .github/workflows/release_tag.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5d47c21 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..010d44a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Release +on: + push: + branches: + - main + tags: + - v* + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + java-version: "8" + distribution: "adopt" + + - name: Build with Maven + run: | + cd BytemanHelper + mvn package -Dmaven.test.skip=true + cd .. + cd ChaosAgent + mvn package -Dmaven.test.skip=true + cd .. + cd AgentInstaller + mvn package -Dmaven.test.skip=true + cd .. + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Configure awscli + run: | + pip3 install awscli + printf "%s\n" ${{ secrets.AWS_ACCESS_KEY }} ${{ secrets.AWS_SECRET_KEY }} ${{ secrets.AWS_REGION }} "json" | aws configure + + - name: Package and Upload + env: + BYTEMAN_VERSION: 4.0.20 + HELPER_VERSION: 0.12 + VERSION: ${{ github.ref_name == 'main' && 'latest' || github.ref_name }} + run: | + $BYTEMAN_DIR=byteman-download-${BYTEMAN_VERSION} + + curl -fsSLO https://downloads.jboss.org/byteman/${BYTEMAN_VERSION}/${BYTEMAN_DIR}-bin.zip + unzip ${BYTEMAN_DIR}-bin.zip + + cp ./BytemanHelper/target/byteman-helper-${HELPER_VERSION}.jar ./${BYTEMAN_DIR}/lib/byteman-helper.jar + cp ./AgentInstaller/target/agent-installer-${HELPER_VERSION}.jar ./${BYTEMAN_DIR}/lib/agent-installer.jar + cp ./ChaosAgent/target/chaos-agent-${HELPER_VERSION}.jar ./${BYTEMAN_DIR}/lib/chaos-agent.jar + cp ./Scripts/bminstall.sh ./${BYTEMAN_DIR}/bin/ + + mv ./byteman-download-${BYTEMAN_VERSION} ./byteman-chaos-mesh-download-${VERSION} + tar czvf ./byteman-chaos-mesh-download-${VERSION}.tar.gz ./byteman-chaos-mesh-download-${VERSION} + + aws s3 cp ./byteman-chaos-mesh-download-${VERSION}.tar.gz ${{ secrets.AWS_BUCKET_NAME }}/byteman-chaos-mesh-download-${VERSION}.tar.gz diff --git a/.github/workflows/release_latest.yml b/.github/workflows/release_latest.yml deleted file mode 100644 index 977c780..0000000 --- a/.github/workflows/release_latest.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Release latest binary -on: - push: - branches: - - main - -jobs: - run: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - java-version: '8' - distribution: 'adopt' - - - uses: actions/setup-python@v2 - with: - python-version: '3.7' - - - name: Configure awscli - run: | - pip3 install awscli - printf "%s\n" ${{ secrets.AWS_ACCESS_KEY }} ${{ secrets.AWS_SECRET_KEY }} ${{ secrets.AWS_REGION }} "json" | aws configure - - - name: Build with Maven - run: | - cd BytemanHelper - mvn package -Dmaven.test.skip=true - cd .. - cd ChaosAgent - mvn package -Dmaven.test.skip=true - cd .. - cd AgentInstaller - mvn package -Dmaven.test.skip=true - cd .. - - - name: Package and Upload - run: | - BYTEMAN_VERSION=4.0.20 - HELPER_VERSION=0.12 - - curl -fsSL -o byteman-download-${BYTEMAN_VERSION}-bin.zip https://downloads.jboss.org/byteman/${BYTEMAN_VERSION}/byteman-download-${BYTEMAN_VERSION}-bin.zip - unzip byteman-download-${BYTEMAN_VERSION}-bin.zip - - cp ./BytemanHelper/target/byteman-helper-${HELPER_VERSION}.jar ./byteman-download-${BYTEMAN_VERSION}/lib/byteman-helper.jar - cp ./AgentInstaller/target/agent-installer-${HELPER_VERSION}.jar ./byteman-download-${BYTEMAN_VERSION}/lib/agent-installer.jar - cp ./ChaosAgent/target/chaos-agent-${HELPER_VERSION}.jar ./byteman-download-${BYTEMAN_VERSION}/lib/chaos-agent.jar - cp ./Scripts/bminstall.sh ./byteman-download-${BYTEMAN_VERSION}/bin/ - - GIT_TAG=latest - mv ./byteman-download-${BYTEMAN_VERSION} ./byteman-chaos-mesh-download-${GIT_TAG} - tar czvf ./byteman-chaos-mesh-download-${GIT_TAG}.tar.gz ./byteman-chaos-mesh-download-${GIT_TAG} - - aws s3 cp ./byteman-chaos-mesh-download-${GIT_TAG}.tar.gz ${{ secrets.AWS_BUCKET_NAME }}/byteman-chaos-mesh-download-${GIT_TAG}.tar.gz \ No newline at end of file diff --git a/.github/workflows/release_tag.yml b/.github/workflows/release_tag.yml deleted file mode 100644 index 30ef6d2..0000000 --- a/.github/workflows/release_tag.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Release tag binary -on: - push: - tags: - - v* - -jobs: - run: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - java-version: '8' - distribution: 'adopt' - - - uses: actions/setup-python@v2 - with: - python-version: '3.7' - - - name: Configure awscli - run: | - pip3 install awscli - printf "%s\n" ${{ secrets.AWS_ACCESS_KEY }} ${{ secrets.AWS_SECRET_KEY }} ${{ secrets.AWS_REGION }} "json" | aws configure - - - name: Build with Maven - run: | - cd BytemanHelper - mvn package -Dmaven.test.skip=true - cd .. - cd ChaosAgent - mvn package -Dmaven.test.skip=true - cd .. - cd AgentInstaller - mvn package -Dmaven.test.skip=true - cd .. - - - name: Package and Upload - run: | - BYTEMAN_VERSION=4.0.20 - HELPER_VERSION=0.12 - - curl -fsSL -o byteman-download-${BYTEMAN_VERSION}-bin.zip https://downloads.jboss.org/byteman/${BYTEMAN_VERSION}/byteman-download-${BYTEMAN_VERSION}-bin.zip - unzip byteman-download-${BYTEMAN_VERSION}-bin.zip - - cp ./BytemanHelper/target/byteman-helper-${HELPER_VERSION}.jar ./byteman-download-${BYTEMAN_VERSION}/lib/byteman-helper.jar - cp ./AgentInstaller/target/agent-installer-${HELPER_VERSION}.jar ./byteman-download-${BYTEMAN_VERSION}/lib/agent-installer.jar - cp ./ChaosAgent/target/chaos-agent-${HELPER_VERSION}.jar ./byteman-download-${BYTEMAN_VERSION}/lib/chaos-agent.jar - cp ./Scripts/bminstall.sh ./byteman-download-${BYTEMAN_VERSION}/bin/ - - GIT_TAG=${GITHUB_REF##*/} - mv ./byteman-download-${BYTEMAN_VERSION} ./byteman-chaos-mesh-download-${GIT_TAG} - tar czvf ./byteman-chaos-mesh-download-${GIT_TAG}.tar.gz ./byteman-chaos-mesh-download-${GIT_TAG} - - aws s3 cp ./byteman-chaos-mesh-download-${GIT_TAG}.tar.gz ${{ secrets.AWS_BUCKET_NAME }}/byteman-chaos-mesh-download-${GIT_TAG}.tar.gz \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eaa15ef..829dc31 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,12 +10,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 8 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'adopt' + java-version: "8" + distribution: "adopt" - name: Test with Maven run: |