-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (114 loc) · 4.39 KB
/
maven-release.yml
File metadata and controls
135 lines (114 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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 "support@pdfix.net"
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