Merge pull request #12 from Certseeds/develop #10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # @Github: https://github.com/Certseeds/algorithm-template-java | |
| # @Organization: SUSTech | |
| # @Author: nanoseeds | |
| # @Date: 2020-07-28 22:43:03 | |
| # @LastEditors: nanoseeds | |
| #@LastEditTime: 2020-07-28 23:43:03 | |
| # This is a basic workflow to help you get started with Actions | |
| name: publish release | |
| # Controls when the action will run. Triggers the workflow on push or pull request | |
| # events but only for the master branch | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| test: | |
| name: test for release | |
| # The type of runner that the job will run on | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ ubuntu-latest ] | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - name: checkout code | |
| uses: actions/checkout@v5 | |
| - name: Setup Java JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: unix-like clean build test | |
| run: mvn clean compile test | |
| # This workflow contains a single job called "build" | |
| build: | |
| name: publish release | |
| if: github.repository == 'Certseeds/algorithm-template-java' | |
| needs: test | |
| runs-on: ubuntu-latest | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - name: checkout code | |
| uses: actions/checkout@v5 | |
| - name: Setup Java JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Branch name | |
| id: branch_name | |
| run: | | |
| echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
| echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
| echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: tag name output | |
| run: | | |
| echo ${SOURCE_NAME};echo ${SOURCE_BRANCH};echo ${SOURCE_TAG} | |
| env: | |
| SOURCE_NAME: ${{ steps.branch_name.outputs.SOURCE_NAME }} | |
| SOURCE_BRANCH: ${{ steps.branch_name.outputs.SOURCE_BRANCH }} | |
| SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }} | |
| - name: Use java and javac | |
| run: javac --version; java --version | |
| - name: run script | |
| run: | | |
| chmod +x ./generate.sh | |
| ./generate.sh | |
| mv ./producer.jar /tmp/producer.jar | |
| - name: zip the packet | |
| working-directory: ./../ | |
| run: | | |
| echo $(pwd) | |
| zip -r script_no_need.zip ./algorithm-template-java -x "*/.git/*" | |
| echo $(pwd) | |
| - name: release | |
| uses: softprops/action-gh-release@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: ./../script_no_need.zip | |
| prerelease: false | |
| generate_release_notes: true | |
| - name: tree | |
| run: tree | |
| release-branch: | |
| name: publish release-branch | |
| if: github.repository == 'Certseeds/algorithm-template-java' | |
| needs: [ test, build ] | |
| # The type of runner that the job will run on | |
| runs-on: ubuntu-latest | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - name: checkout code | |
| uses: actions/checkout@v5 | |
| - name: Branch name | |
| id: branch_name | |
| run: | | |
| echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
| - name: tag name output | |
| run: | | |
| echo ${SOURCE_NAME}; | |
| env: | |
| SOURCE_NAME: ${{ steps.branch_name.outputs.SOURCE_NAME }} | |
| - name: git operations | |
| run: | | |
| git config --global user.name 'Certseeds' | |
| git config --global user.email '51754303+Certseeds@users.noreply.github.com' | |
| git checkout -b release | |
| - name: run script | |
| run: | | |
| chmod +x ./generate.sh | |
| ./generate.sh | |
| mv ./producer.jar /tmp/producer.jar | |
| - name: git operations | |
| working-directory: ./ | |
| run: | | |
| git add . | |
| git commit -am "release ${{ steps.branch_name.outputs.SOURCE_NAME }}" | |
| git push --set-upstream origin release --force |