diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d0beae0..18e6583 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,11 +1,9 @@ -name: Build DCM Project and Create Release +name: CI on: push: branches: - - actions # Triggers on push to the 'actions' branch - tags: - - '*' # Triggers on any tag creation (for release) + - actions # This workflow will be triggered only for pushes to the "actions" branch jobs: build: @@ -15,57 +13,42 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up Java + uses: actions/setup-java@v2 with: - distribution: 'temurin' # You can change this to another JDK distribution if needed - java-version: '8' + java-version: '8' # Use the appropriate JDK version - - name: Install Apache Ant 1.9.9 - run: | - wget https://archive.apache.org/dist/ant/binaries/apache-ant-1.9.9-bin.zip - unzip apache-ant-1.9.9-bin.zip - sudo mv apache-ant-1.9.9 /usr/local/ant - echo "export PATH=\$PATH:/usr/local/ant/bin" >> $GITHUB_ENV - - - name: Verify Ant installation - run: ant -version - - - name: Set build version - run: echo "VERSION=${GITHUB_REF#refs/tags/}.${GITHUB_SHA:0:7}" >> $GITHUB_ENV + - name: Install Ant + run: sudo apt-get install -y ant - name: Build the project - env: - VERSION: ${{ env.VERSION }} - run: ant -Dplugin.version=${{ env.VERSION }} + run: ant -Dplugin.version=${{ github.sha }} - name: Archive artifacts - uses: actions/upload-artifact@v3 - with: - name: artifacts - path: | - dist/datapower-v*.zip - dist/dcm.jar + run: | + mkdir -p dist + cp dist/datapower-v*.zip dist/ + cp dist/dcm.jar dist/ release: runs-on: ubuntu-20.04 - needs: build # Release job depends on successful completion of build job + needs: build # Release job depends on successful completion of the build job steps: - name: Checkout code uses: actions/checkout@v2 - name: Create GitHub release - id: create_release # Add an ID to this step + id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ github.ref_name }} # Use the tag name directly - release_name: "Release ${{ github.ref_name }}" # Use the tag name for the release + tag_name: "actions-${{ github.sha }}" # Tag name format + release_name: "Plugin version: ${{ github.sha }}" # Release name format body: | - Release notes for ${{ github.ref_name }}. - - Plugin version: ${{ env.VERSION }} + Release notes for actions-${{ github.sha }}. + - Plugin version: ${{ github.sha }} draft: false prerelease: false @@ -74,7 +57,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # Reference the output from create_release step - asset_path: dist/datapower-v${{ env.VERSION }}.zip - asset_name: datapower-v${{ env.VERSION }}.zip + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/datapower-v*.zip # Path to your zip file + asset_name: datapower-v.zip # Name of the asset asset_content_type: application/zip