88 required : true
99
1010jobs :
11+ setup_deployment :
12+ name : Setup Deployment
13+ runs-on : ubuntu-24.04
14+ outputs :
15+ environment : ${{ steps.set-env.outputs.environment }}
16+ version : ${{ steps.set-env.outputs.version }}
17+ steps :
18+ - name : Validate and Determine Build Environment
19+ id : set-env
20+ run : |
21+ VERSION="${{ github.event.inputs.version_tag }}"
22+
23+ # Validate version format and determine environment
24+ if [[ "$VERSION" =~ ^v11\.[0-9]+\.[0-9]+$ ]]; then
25+ echo "Production environment detected"
26+ echo "environment=prod" >> $GITHUB_OUTPUT
27+ echo "version=$VERSION" >> $GITHUB_OUTPUT
28+
29+ elif [[ "$VERSION" =~ ^v11\.[0-9]+\.[0-9]+-beta\.[0-9]+$ ]]; then
30+ echo "Beta environment detected"
31+ echo "environment=beta" >> $GITHUB_OUTPUT
32+ echo "version=$VERSION" >> $GITHUB_OUTPUT
33+
34+ elif [[ "$VERSION" =~ ^v11\.[0-9]+\.[0-9]+-rc\.[0-9]+$ ]]; then
35+ echo "RC environment detected"
36+ echo "environment=rc" >> $GITHUB_OUTPUT
37+ echo "version=$VERSION" >> $GITHUB_OUTPUT
38+
39+ else
40+ echo "ERROR: Invalid version format. Version must match one of:"
41+ echo " - v11.x.x (production)"
42+ echo " - v11.x.x-beta.x (beta)"
43+ echo " - v11.x.x-rc.x (release candidate)"
44+ exit 1
45+ fi
46+
1147 build :
1248 name : Build
1349 runs-on : ubuntu-24.04
50+ needs : setup_deployment
51+ if : ${{ needs.setup_deployment.outputs.environment != '' }}
1452 steps :
1553 - name : Check out code into the right branch
1654 uses : actions/checkout@v4
@@ -22,25 +60,28 @@ jobs:
2260 id : go
2361
2462 - name : Build
63+ working-directory : ./installer
2564 env :
2665 GOOS : linux
2766 GOARCH : amd64
2867 run : |
29- cd "${{ github.workspace }}/installer/config"
30- sed -i 's|const INSTALLER_VERSION = ""|const INSTALLER_VERSION = "${{ secrets.AGENT_SECRET_PREFIX }}"|' const.go
31- cd "${{ github.workspace }}/installer"
32- go build -o installer -v .
68+ echo "Building Installer..."
69+ go build -o installer -v -ldflags "\
70+ -X 'github.com/utmstack/UTMStack/installer/config.DEFAULT_BRANCH=${{ needs.setup_deployment.outputs.environment }}' \
71+ -X 'github.com/utmstack/UTMStack/installer/config.INSTALLER_VERSION=${{ needs.setup_deployment.outputs.version }}' \
72+ -X 'github.com/utmstack/UTMStack/installer/config.REPLACE=${{ secrets.CM_ENCRYPT_SALT }}' \
73+ -X 'github.com/utmstack/UTMStack/installer/config.PUBLIC_KEY=${{ secrets.CM_SIGN_PUBLIC_KEY }}'" .
3374
3475 - name : Create Release
3576 id : create_release
3677 uses : softprops/action-gh-release@v2
3778 env :
3879 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3980 with :
40- tag_name : ${{ github.event.inputs.version_tag }}
41- name : ${{ github.event.inputs.version_tag }}
81+ tag_name : ${{ needs.setup_deployment.outputs.version }}
82+ name : ${{ needs.setup_deployment.outputs.version }}
4283 body_path : ./CHANGELOG.md
4384 draft : false
44- prerelease : false
85+ prerelease : ${{ needs.setup_deployment.outputs.environment != 'prod' }}
4586 files : |
4687 ./installer/installer
0 commit comments