99 pull_request : # TEMPORARY: Remove this block after testing
1010 branches :
1111 - main
12- # Replace this entire block with nothing. It should look like this:
13- # on:
14- # workflow_run:
15- # workflows:
16- # - Test on Pull Request and Push
17- # types:
18- # - completed
1912
2013env :
21- IMAGE_NAME : shawn636 /mini-ftp
14+ IMAGE_NAME : shawnlong636 /mini-ftp
2215 MINORS_TO_KEEP : 3
2316
2417jobs :
2518 build-and-release :
2619 runs-on : ubuntu-latest
2720
28- # TEMPORARY: Add 'github.event_name == "pull_request"' for testing; remove it later
2921 if : ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'pull_request' }}
30- # Replace this with:
31- # if: ${{ github.event.workflow_run.conclusion == 'success' }}
3222
3323 steps :
3424 - name : Checkout Repository
3525 uses : actions/checkout@v4
3626 with :
37- ref : ${{ github.event.pull_request.head.ref || github.ref }} # Ensure we are on the correct branch
27+ ref : ${{ github.event.pull_request.head.ref || github.ref }}
3828
3929 # Bump Version
4030 - name : Bump Version (if triggered by bot or cron)
@@ -53,68 +43,24 @@ jobs:
5343 new_version="$major.$minor.$new_patch"
5444
5545 echo $new_version > $VERSION_FILE
56- echo "VERSION=$new_version" >> $GITHUB_ENV
57- echo "version=$ new_version" >> $GITHUB_OUTPUT
46+ echo "Exporting VERSION=${ new_version}"
47+ echo "VERSION=${ new_version} " >> $GITHUB_ENV
5848
59- # Commit Version Update (only if VERSION file was updated)
60- - name : Commit Version Update
61- if : steps.version_bump.outputs.version != ''
49+ # Debug Version (ensure it's loaded correctly)
50+ - name : Debug Version
6251 run : |
63- git config --global user.name "github-actions[bot]"
64- git config --global user.email "github-actions[bot]@users.noreply.github.com"
65- git add VERSION
66- git diff --cached --exit-code || git commit --no-verify -m "Bump version to ${{ steps.version_bump.outputs.version }}"
67- git push
68-
69- - name : Set up QEMU
70- uses : docker/setup-qemu-action@v2
71-
72- - name : Set up Docker Buildx
73- uses : docker/setup-buildx-action@v2
74-
75- # Cache Docker Compose
76- - name : Cache Docker Compose
77- id : cache-compose
78- uses : actions/cache@v3
79- with :
80- path : /usr/local/bin/docker-compose
81- key : compose-${{ runner.os }}-v2.19.1
82-
83- - name : Install Docker Compose (if not cached)
84- if : steps.cache-compose.outputs.cache-hit != 'true'
85- run : |
86- sudo curl -L "https://github.com/docker/compose/releases/download/v2.19.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
87- sudo chmod +x /usr/local/bin/docker-compose
88-
89- - name : Login to Docker Hub
90- uses : docker/login-action@v2
91- with :
92- username : ${{ secrets.DOCKER_HUB_USERNAME }}
93- password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
94-
95- - name : Create .env File
96- run : |
97- echo "Generating .env file..."
98- cat <<EOF > .env
99- DUCKDNSTOKEN=${{ secrets.DUCKDNSTOKEN }}
100- CONFIG_ONLY_TEST_USER_PASS=${{ secrets.CONFIG_ONLY_TEST_USER_PASS }}
101- CONFIG_ONLY_SSL_TEST_USER1_PASS=${{ secrets.CONFIG_ONLY_SSL_TEST_USER1_PASS }}
102- CONFIG_ONLY_SSL_TEST_USER2_PASS=${{ secrets.CONFIG_ONLY_SSL_TEST_USER2_PASS }}
103- ENV_OVERRIDE_TEST_USER1_PASS=${{ secrets.ENV_OVERRIDE_TEST_USER1_PASS }}
104- ENV_OVERRIDE_TEST_USER2_PASS=${{ secrets.ENV_OVERRIDE_TEST_USER2_PASS }}
105- ENV_OVERRIDE_SSL_TEST_USER1_PASS=${{ secrets.ENV_OVERRIDE_SSL_TEST_USER1_PASS }}
106- ENV_OVERRIDE_SSL_TEST_USER2_PASS=${{ secrets.ENV_OVERRIDE_SSL_TEST_USER2_PASS }}
107- EOF
52+ VERSION=$(cat VERSION)
53+ echo "VERSION is: $VERSION"
10854
55+ # Build and Push Docker Image
10956 - name : Build and Push Docker Image
11057 run : |
111- echo "Building image with version: ${VERSION}"
58+ VERSION=$(cat VERSION)
59+ echo "Building image with version: $VERSION"
11260 docker buildx build --push \
11361 --platform linux/amd64,linux/arm64 \
114- --tag ${{ env.IMAGE_NAME }}:${{ env. VERSION }} \
62+ --tag ${{ env.IMAGE_NAME }}:$VERSION \
11563 .
116- env :
117- VERSION : ${{ env.VERSION }} # Ensure VERSION is passed as an environment variable
11864
11965 - name : Cleanup Old Docker Images
12066 run : |
12470 done
12571
12672 - name : Finalize Release
127- run : echo "Successfully released version ${{ env. VERSION }} "
73+ run : echo "Successfully released version $(cat VERSION) "
0 commit comments