Updated config.json - multiple actions support #26
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: Maven Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # Trigger release on version tag, e.g., v1.0.0 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v2 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v2 | |
| with: | |
| java-version: '11' | |
| distribution: 'adopt' | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/*.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: Download and unzip JAR file | |
| run: | | |
| mkdir -p lib | |
| curl -L https://github.com/pdfix/pdfix_sdk_builds/releases/download/v8.4.3/java8-net.pdfix.pdfixlib-8.4.3.jar.zip -o lib/pdfixlib-8.4.3.jar.zip | |
| unzip lib/pdfixlib-8.4.3.jar.zip -d lib/ | |
| mvn install:install-file -Dfile=lib/net.pdfix.pdfixlib-8.4.3.jar -DgroupId=net.pdfix -DartifactId=net.pdfix.pdfixlib -Dversion=8.4.3 -Dpackaging=jar | |
| - name: Extract version from tag | |
| id: extract_version | |
| run: | | |
| # Extract the version from the tag (e.g., "v1.2.1" -> "1.2.1") | |
| VERSION=$(echo ${GITHUB_REF#refs/tags/v}) | |
| echo "Version to set: $VERSION" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Set version in pom.xml | |
| run: | | |
| mvn versions:set -DnewVersion=${{ steps.extract_version.outputs.version }} | |
| - name: Update version in config.json | |
| run: | | |
| VERSION=${{ steps.extract_version.outputs.version }} | |
| # Use sed to replace the old version in the "program" field of config.json | |
| sed -i "s/-[0-9]*\.[0-9]*\.[0-9]*.jar/-${VERSION}.jar/" config.json | |
| sed -i "s/\"version\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"version\": \"${VERSION}\"/" config.json | |
| - name: Build with Maven | |
| run: | | |
| mvn compile | |
| mvn test | |
| mvn package | |
| # run: mvn clean install -DskipTests | |
| - name: Prepare files for release | |
| id: prepare-for-release | |
| run: | | |
| VERSION=${{ steps.extract_version.outputs.version }} | |
| RELEASE_DIR=net.pdfix.validate-pdf-${VERSION} | |
| echo "release_dir=$RELEASE_DIR" >> $GITHUB_OUTPUT | |
| mkdir ${RELEASE_DIR} | |
| cp target/net.pdfix.*.jar ${RELEASE_DIR}/ | |
| cp config.json ${RELEASE_DIR}/ | |
| - name: Zip the release files | |
| run: | | |
| VERSION=${{ steps.extract_version.outputs.version }} | |
| RELEASE_DIR=${{ steps.prepare-for-release.outputs.release_dir }} | |
| zip -r "net.pdfix.validate-pdf-${VERSION}.zip" $RELEASE_DIR/ | |
| # - name: Publish Release | |
| # run: mvn deploy -P release -DskipTests | |
| # env: | |
| # MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
| # MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| net.pdfix.validate-pdf-${{ steps.extract_version.outputs.version }}.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |