| # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created |
| # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path |
| name: mvn package with test case |
| on: |
| pull_request: |
| types: [ opened, reopened, synchronize ] |
| release: |
| types: [ created ] |
| |
| jobs: |
| # Label of the runner job |
| runner-job: |
| # You must use a Linux environment when using service containers or container jobs |
| runs-on: ubuntu-latest |
| permissions: |
| contents: read |
| packages: write |
| |
| steps: |
| # Downloads a copy of the code in your repository before running CI tests |
| - name: Create RocketMQ container |
| run: | |
| docker pull apache/rocketmq:5.1.0 |
| echo 'brokerClusterName = DefaultCluster |
| brokerName = broker-a |
| brokerId = 0 |
| deleteWhen = 04 |
| fileReservedTime = 48 |
| brokerRole = ASYNC_MASTER |
| flushDiskType = ASYNC_FLUSH |
| autoCreateTopicEnable = true |
| autoCreateSubscriptionGroup = true |
| brokerIP1 =127.0.0.1'>>/opt/broker.conf |
| docker run -d --name rmqnamesrv -p 9876:9876 apache/rocketmq:5.1.0 sh mqnamesrv autoCreateTopicEnable=true |
| docker run -d --name rmqbroker -p 10911:10911 -p 10909:10909 --link rmqnamesrv:namesrv -v /opt/broker.conf:/opt/rocketmq-5.1.0/conf/broker.conf -e "NAMESRV_ADDR=rmqnamesrv:9876" apache/rocketmq:5.1.0 sh mqbroker autoCreateTopicEnable=true -c /opt/rocketmq-5.1.0/conf/broker.conf |
| |
| - name: Wait for RocketMQ namesrv container to be ready |
| run: | |
| docker exec rmqnamesrv sh -c 'while ! nc -z localhost 9876; do sleep 1; done' |
| |
| - name: Wait for RocketMQ broker container to be ready |
| run: | |
| docker exec rmqbroker sh -c 'while ! nc -z localhost 10911; do sleep 1; done' |
| - uses: actions/checkout@v4 |
| - name: Set up JDK 8 |
| uses: actions/setup-java@v4 |
| with: |
| java-version: '8' |
| distribution: 'temurin' |
| server-id: github # Value of the distributionManagement/repository/id field of the pom.xml |
| settings-path: ${{ github.workspace }} # location for the settings.xml file |
| |
| - name: Get Maven Project Version |
| id: get_version |
| run: | |
| echo "MAVEN_PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV |
| |
| - name: Upload source-release |
| uses: actions/upload-artifact@v4 |
| with: |
| name: rocketmq-eventbridge-${{ env.MAVEN_PROJECT_VERSION}}-source-release |
| path: ./* |
| |
| - name: Build with Maven |
| run: mvn -B package --file pom.xml |
| |
| - name: Rename artifact |
| run: | |
| mv "dist/target/rocketmq-eventbridge-dist-${MAVEN_PROJECT_VERSION}/rocketmq-eventbridge" "rocketmq-eventbridge-${MAVEN_PROJECT_VERSION}-bin-release" |
| |
| - name: Upload bin-release |
| uses: actions/upload-artifact@v4 |
| with: |
| name: rocketmq-eventbridge-${{ env.MAVEN_PROJECT_VERSION}}-bin-release |
| path: rocketmq-eventbridge-${{ env.MAVEN_PROJECT_VERSION}}-bin-release/* |
| |