1- name : Create GitHub Release
1+ name : Create Unified Release
22
33on :
44 push :
55 tags :
6- - ' v*' # Trigger this workflow on tags like v0.1.0, v1.2.3, etc.
6+ - ' v*'
77
88jobs :
9- build-and -release :
9+ create -release :
1010 runs-on : ubuntu-latest
1111 permissions :
1212 contents : write
13+ outputs :
14+ upload_url : ${{ steps.create_release.outputs.upload_url }}
15+ release_id : ${{ steps.create_release.outputs.id }}
1316 steps :
1417 - name : Check out code
15- uses : actions/checkout@v3
18+ uses : actions/checkout@v4
1619 with :
17- # Fetch all history so we can generate notes from the previous tag
1820 fetch-depth : 0
1921
2022 - name : Generate Release Notes
2123 id : release_notes
2224 run : |
23- # Make the script executable
2425 chmod +x ./scripts/generate_release_notes.sh
25- # Run the script and store its output. The output is captured by using
26- # a special GitHub Actions syntax to set the step's output variable.
2726 NOTES=$(./scripts/generate_release_notes.sh)
28- # This is a bit of a hack to make the multiline notes work in the next step
2927 NOTES="${NOTES//'%'/'%25'}"
3028 NOTES="${NOTES//$'\n'/'%0A'}"
3129 NOTES="${NOTES//$'\r'/'%0D'}"
3230 echo "notes=$NOTES" >> $GITHUB_OUTPUT
3331
34- - name : Create Release
32+ - name : Create Draft Release
33+ id : create_release
3534 uses : softprops/action-gh-release@v1
3635 with :
37- # The GITHUB_TOKEN is a secret automatically provided by GitHub Actions
38- # so you don't have to create it manually. It has permissions to
39- # create releases in your repository.
4036 token : ${{ secrets.GITHUB_TOKEN }}
4137 body : ${{ steps.release_notes.outputs.notes }}
4238 name : Release ${{ github.ref_name }}
43- draft : false
39+ draft : true # Create a draft first
4440 prerelease : false
41+
42+ build-and-upload :
43+ runs-on : ubuntu-latest
44+ needs : create-release
45+ steps :
46+ - name : Check out code
47+ uses : actions/checkout@v4
48+ - name : Install Go
49+ uses : actions/setup-go@v5
50+ with :
51+ go-version : ' 1.22'
52+
53+ - name : Build the Debian package
54+ run : |
55+ chmod +x ./scripts/build_packages.sh
56+ bash ./scripts/build_packages.sh ${{ github.ref_name }}
57+
58+ - name : Upload Debian package to draft release
59+ uses : actions/upload-release-asset@v1
60+ with :
61+ upload_url : ${{ needs.create-release.outputs.upload_url }}
62+ asset_path : ./docker-ai_${{ github.ref_name }}_amd64.deb
63+ asset_name : docker-ai_${{ github.ref_name }}_amd64.deb
64+ asset_content_type : application/vnd.debian.binary-package
4565 env :
46- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
66+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67+
68+ update-homebrew-tap :
69+ runs-on : ubuntu-latest
70+ needs : build-and-upload
71+ steps :
72+ - name : Checkout Homebrew tap repository
73+ uses : actions/checkout@v4
74+ with :
75+ repository : Aj7Ay/homebrew-tap
76+ token : ${{ secrets.PAT_FOR_HOMEBREW_TAP }}
77+ path : homebrew-tap
78+
79+ - name : Calculate SHA256 of the new release tarball
80+ id : shasum
81+ run : |
82+ RELEASE_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${{ github.ref_name }}.tar.gz"
83+ SHA256=$(curl -L $RELEASE_URL | shasum -a 256 | cut -d' ' -f1)
84+ echo "sha256=${SHA256}" >> $GITHUB_ENV
85+
86+ - name : Update Homebrew formula
87+ run : |
88+ cd homebrew-tap
89+ sed -i "s|url \".*\"|url \"https://github.com/${{ github.repository }}/archive/refs/tags/${{ github.ref_name }}.tar.gz\"|" docker-ai.rb
90+ sed -i "s/sha256 \".*\"/sha256 \"${{ env.sha256 }}\"/" docker-ai.rb
91+
92+ - name : Commit and push changes
93+ run : |
94+ cd homebrew-tap
95+ git config --global user.name 'github-actions[bot]'
96+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
97+ git add docker-ai.rb
98+ if git diff --staged --quiet; then
99+ echo "No changes to the formula to commit."
100+ else
101+ git commit -m "Update docker-ai to ${{ github.ref_name }}"
102+ git push
103+ fi
104+
105+ publish-release :
106+ runs-on : ubuntu-latest
107+ needs : update-homebrew-tap
108+ steps :
109+ - name : Publish the release
110+ uses : softprops/action-gh-release@v1
111+ with :
112+ token : ${{ secrets.GITHUB_TOKEN }}
113+ id : ${{ needs.create-release.outputs.release_id }}
114+ draft : false # This publishes the release
0 commit comments