|
| 1 | +name: Version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +jobs: |
| 7 | + test: |
| 8 | + name: Test |
| 9 | + runs-on: ubuntu-latest |
| 10 | + env: |
| 11 | + SHARED: /tmp/workdir/pki |
| 12 | + steps: |
| 13 | + - name: Install dependencies |
| 14 | + run: | |
| 15 | + sudo apt-get update |
| 16 | + sudo apt-get -y install xmlstarlet |
| 17 | +
|
| 18 | + - name: Clone repository |
| 19 | + uses: actions/checkout@v7 |
| 20 | + |
| 21 | + - name: Get version number from RPM spec |
| 22 | + run: | |
| 23 | + MAJOR_VERSION=$(sed -n 's/^%global *major_version *\(.*\)$/\1/p' pki.spec) |
| 24 | + MINOR_VERSION=$(sed -n 's/^%global *minor_version *\(.*\)$/\1/p' pki.spec) |
| 25 | + UPDATE_VERSION=$(sed -n 's/^%global *update_version *\(.*\)$/\1/p' pki.spec) |
| 26 | +
|
| 27 | + VERSION=$MAJOR_VERSION.$MINOR_VERSION.$UPDATE_VERSION |
| 28 | + echo "VERSION=$VERSION" | tee -a $GITHUB_ENV |
| 29 | +
|
| 30 | + - name: Check version numbers in pom.xml |
| 31 | + run: | |
| 32 | + echo -n "$VERSION-SNAPSHOT" > expected |
| 33 | +
|
| 34 | + for filename in $(find . -name pom.xml); do |
| 35 | + echo "Checking version number in $filename" |
| 36 | +
|
| 37 | + if [ "$filename" == "./pom.xml" ]; then |
| 38 | + xmlstarlet sel -t -v '/_:project/_:version' $filename > actual |
| 39 | + else |
| 40 | + xmlstarlet sel -t -v '/_:project/_:parent/_:version' $filename > actual |
| 41 | + fi |
| 42 | +
|
| 43 | + diff expected actual |
| 44 | + done |
| 45 | +
|
| 46 | + - name: Setup git |
| 47 | + run: | |
| 48 | + sudo apt-get update |
| 49 | + sudo apt-get -y install git |
| 50 | +
|
| 51 | + git config --global user.name "Dr. John Doe" |
| 52 | + git config --global user.email jdoe@example.com |
| 53 | +
|
| 54 | + - name: Update to version with a phase |
| 55 | + run: | |
| 56 | + ./update_version.sh 12 1 0 beta1 |
| 57 | +
|
| 58 | + git show |
| 59 | + git tag --points-at HEAD > actual |
| 60 | + echo v12.1.0-beta1 > expected |
| 61 | + diff expected actual |
| 62 | +
|
| 63 | + - name: Update to version without a phase |
| 64 | + run: | |
| 65 | + ./update_version.sh 12 1 0 |
| 66 | +
|
| 67 | + git show |
| 68 | + git tag --points-at HEAD > actual |
| 69 | + echo v12.1.0 > expected |
| 70 | +
|
| 71 | + diff expected actual |
| 72 | +
|
| 73 | + - name: Update to version with a phase again |
| 74 | + run: | |
| 75 | + ./update_version.sh 12 2 0 alpha1 |
| 76 | +
|
| 77 | + git show |
| 78 | + git tag --points-at HEAD > actual |
| 79 | + echo v12.2.0-alpha1 > expected |
| 80 | +
|
| 81 | + diff expected actual |
0 commit comments