PVQ-3930 External Actions - Unite action names, subtypes, input and o… #39
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*.*.*' # Matches version tags like v1.0.0 | |
| env: | |
| ACTION_NAMESPACE: pdfix | |
| ACTION_REPOSITORY: validate-pdf-pdfix | |
| 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: Set env variables | |
| run: echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV | |
| - 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: Update config.json version | |
| run: chmod +x update_version.sh && ./update_version.sh ${{ env.tag }} | |
| - 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: | | |
| RELEASE_DIR=net.pdfix.validate-pdf-${{ env.tag }} | |
| 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: | | |
| RELEASE_DIR=${{ steps.prepare-for-release.outputs.release_dir }} | |
| zip -r "net.pdfix.validate-pdf-${{ env.tag }}.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-${{ env.tag }}.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload to FTP | |
| run: | | |
| curl -T config.json ftp.pdfix.net/update-service/v1/actions/${{ env.ACTION_NAMESPACE }}/${{ env.ACTION_REPOSITORY }}/config.json --user "${{ secrets.FTP_USERNAME }}:${{ secrets.FTP_PASSWORD }}" --ftp-create-dirs | |
| - name: Prepare directory for versions repository | |
| run: mkdir -p pdfix-version-updates | |
| - name: Checkout versions repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: pdfix/pdfix-version-updates | |
| path: pdfix-version-updates | |
| token: ${{ secrets.PAT_VERSIONS }} | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Update action version and date in versions repository | |
| run: | | |
| cd pdfix-version-updates/v1 | |
| TODAY=$(date +%Y-%m-%d) | |
| jq --indent 4 '(.["pdfix-actions"][] | select(.name == "${{ env.ACTION_NAMESPACE }}/${{ env.ACTION_REPOSITORY }}")) |= . + { | |
| "version": "${{ env.tag }}", | |
| "release_date": "'"$TODAY"'" | |
| }' versions.json > tmp.json | |
| mv tmp.json versions.json | |
| cat versions.json | |
| - name: Commit and Push changes into versions repository | |
| run: | | |
| cd pdfix-version-updates | |
| git config user.name "PDFix Support" | |
| git config user.email "[email protected]" | |
| git add v1/versions.json | |
| git commit -m "${{ env.ACTION_NAMESPACE }}/${{ env.ACTION_REPOSITORY }} ${{ env.tag }}" | |
| git push | |
| - name: Tag latest commit with increment in versions repository | |
| run: | | |
| cd pdfix-version-updates | |
| git pull | |
| if git describe --exact-match --tags HEAD > /dev/null 2>&1; then | |
| echo "HEAD already has a tag — skipping tagging." | |
| else | |
| latest_tag=$(git tag -l "v*.*.*" | sort -V | tail -n 1) | |
| echo "Latest tag is: $latest_tag" | |
| version=${latest_tag#v} | |
| IFS='.' read -r major minor patch <<< "$version" | |
| patch=$((patch + 1)) | |
| new_tag="v$major.$minor.$patch" | |
| git tag -a "$new_tag" -m "Release $new_tag" | |
| git push origin "$new_tag" | |
| echo "Tagged HEAD with: $new_tag" | |
| fi |