forked from Hithomelabs/CFTunnels
Trying to pass variables between steps using outputs
This commit is contained in:
parent
1980b49272
commit
cd4b2ae2d8
@ -6,8 +6,6 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
@ -18,22 +16,5 @@ jobs:
|
||||
java-version: '17'
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: Get latest tag
|
||||
id: get_tag
|
||||
run: |
|
||||
export "VERSION=$(git describe --tags --abbrev=0)" >> $GITEA_ENV
|
||||
echo "${VERSION}"
|
||||
export "MAJOR=$(echo ${VERSION} | /usr/bin/cut -d "." -f 1)" >> $GITEA_ENV
|
||||
echo "MAJOR=${MAJOR}"
|
||||
export "MINOR=$(echo ${VERSION} | cut -d "." -f 2)" >> $GITEA_ENV
|
||||
echo "MINOR=${MINOR}"
|
||||
export "PATCH=$(echo ${VERSION} | cut -d "." -f 3)" >> $GITEA_ENV
|
||||
echo "PATCH=${PATCH}"
|
||||
- name: Increment version
|
||||
run: |
|
||||
. $GITEA_ENV
|
||||
export "PATCH=$((${PATCH} + 1))" >> $GITEA_ENV
|
||||
export "NEW_VERSION=$(echo ${MAJOR}.${MINOR}.${PATCH})" >> $GITEA_ENV
|
||||
echo "NEW_VERSION=${NEW_VERSION}"
|
||||
- name: Gradle build
|
||||
run: ./gradlew build --info
|
||||
@ -18,29 +18,28 @@ jobs:
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '17'
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: Get latest tag
|
||||
id: get_tag
|
||||
run: |
|
||||
export "VERSION=$(git describe --tags --abbrev=0)" >> $GITEA_ENV
|
||||
echo "${VERSION}"
|
||||
export "MAJOR=$(echo ${VERSION} | /usr/bin/cut -d "." -f 1)" >> $GITEA_ENV
|
||||
echo "MAJOR=${MAJOR}"
|
||||
export "MINOR=$(echo ${VERSION} | cut -d "." -f 2)" >> $GITEA_ENV
|
||||
echo "MINOR=${MINOR}"
|
||||
export "PATCH=$(echo ${VERSION} | cut -d "." -f 3)" >> $GITEA_ENV
|
||||
echo "PATCH=${PATCH}"
|
||||
VERSION=$(git describe --tags --abbrev=0)
|
||||
echo "VERSION=${VERSION}" >> $GITEA_OUTPUT
|
||||
MAJOR=$(echo ${VERSION} | cut -d "." -f 1)
|
||||
echo "MAJOR=${MAJOR}" >> $GITEA_OUTPUT
|
||||
MINOR=$(echo ${VERSION} | cut -d "." -f 2)
|
||||
echo "MINOR=${MINOR}" >> $GITEA_OUTPUT
|
||||
PATCH=$(echo ${VERSION} | cut -d "." -f 3)
|
||||
echo "PATCH=${PATCH}" >> $GITEA_OUTPUT
|
||||
- name: Increment version
|
||||
id: calc_new_tag
|
||||
run: |
|
||||
. $GITEA_ENV
|
||||
export "PATCH=$((${PATCH} + 1))" >> $GITEA_ENV
|
||||
export "NEW_VERSION=$(echo ${MAJOR}.${MINOR}.${PATCH})" >> $GITEA_ENV
|
||||
echo "NEW_VERSION=${NEW_VERSION}"
|
||||
- name: Extract commit message
|
||||
run: echo "COMMIT_MESSAGE=$(git log -1 --pretty=%B)"
|
||||
echo "NEW_PATCH=$((${{ steps.get_id.outputs.PATCH }} + 1))" >> $GITEA_OUTPUT
|
||||
echo "NEW_VERSION=$( ${{ steps.get_id.outputs.MAJOR }}.${{ steps.get_id.outputs.MINOR }}.${{ steps.get_id.outputs.NEW_PATCH }})" >> $GITEA_OUTPUT
|
||||
- name: Create and push tag
|
||||
run: |
|
||||
git tag -a ${NEW_VERSION} -m "${COMMIT_MESSAGE}"
|
||||
git push origin ${NEW_VERSION}
|
||||
git tag -a ${{ steps.calc_new_tag.outputs.NEW_VERSION }} -m "Pushing new version ${{ steps.calc_new_tag.outputs.NEW_VERSION }}"
|
||||
git push origin ${{ steps.calc_new_tag.outputs.NEW_VERSION }}
|
||||
- name: Log in to Gitea Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
@ -48,10 +47,10 @@ jobs:
|
||||
username: hitanshu
|
||||
password: ${{ secrets.TOKEN }}
|
||||
- name: Gradle build
|
||||
run: ./gradlew bootBuildImage --imageName=192.168.0.100:8928/hithomelabs/cftunnels:${NEW_VERSION}
|
||||
run: ./gradlew bootBuildImage --imageName=192.168.0.100:8928/hithomelabs/cftunnels:${{ steps.calc_new_tag.outputs.NEW_VERSION }}
|
||||
- name: Tag image as test
|
||||
run: docker tag 192.168.0.100:8928/hithomelabs/cftunnels:${NEW_VERSION} 192.168.0.100:8928/hithomelabs/cftunnels:test
|
||||
run: docker tag 192.168.0.100:8928/hithomelabs/cftunnels:${{ steps.calc_new_tag.outputs.NEW_VERSION }} 192.168.0.100:8928/hithomelabs/cftunnels:test
|
||||
- name: Push to Gitea Registry
|
||||
run: |
|
||||
docker push 192.168.0.100:8928/hithomelabs/cftunnels:test
|
||||
docker push 192.168.0.100:8928/hithomelabs/cftunnels:${NEW_VERSION}
|
||||
docker push 192.168.0.100:8928/hithomelabs/cftunnels:${{ steps.calc_new_tag.outputs.NEW_VERSION }}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user