0.1.1 #9
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
| name: Build and Release | |
| on: | |
| release: | |
| types: | |
| - published # Runs when a release is created or published | |
| permissions: | |
| contents: write # <-- Required to upload release assets | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout source | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.release.tag_name }} | |
| # Step 2: Install xmllint (libxml2-utils) | |
| - name: Install xmllint | |
| run: sudo apt-get update && sudo apt-get install -y libxml2-utils | |
| # Step 3: Set up Java 8 | |
| - name: Set up Java 8 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '8' | |
| # Step 4: Install Python 3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| # Step 5: Verify Docker is available | |
| - name: Verify Docker | |
| run: docker --version | |
| # Step 6: Cache Maven dependencies | |
| - name: Cache Maven repository | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| # Step 7: Extract version from pom.xml | |
| - name: Extract provider version | |
| run: | | |
| VERSION=$(xmllint --xpath "string(//*[local-name()='project']/*[local-name()='properties']/*[local-name()='provider.version'])" pom.xml) | |
| echo "Provider version detected: $VERSION" | |
| if [ -z "$VERSION" ]; then | |
| echo "ERROR: Could not extract provider.version from pom.xml" >&2 | |
| exit 1 | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| # Step 8: Build project using Maven | |
| - name: Build with Maven | |
| run: mvn package -PcollectDependencies -Duser.id=$(id -u) | |
| # Optional: Debugging to confirm output | |
| - name: List target directory | |
| run: ls -lh target | |
| # Step 9: Upload build artifact to GitHub release | |
| - name: Upload release asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ github.event.release.upload_url }} | |
| asset_path: ./target/phpIPAM-${{ env.VERSION }}.zip | |
| asset_name: phpIPAM-${{ env.VERSION }}.zip | |
| asset_content_type: application/zip |