@@ -5,47 +5,60 @@ permissions:
55
66on :
77 workflow_dispatch :
8+ inputs :
9+ tag :
10+ description : " Existing tag (e.g. vX.X.X) to build release assets for. Leave blank to use the ref this workflow is dispatched from."
11+ required : false
12+ type : string
813 push :
914 tags :
1015 # Semantic versions are allowed (i.e. `v1.2.3`)
1116 - " v[0-9]+.[0-9]+.[0-9]+"
1217 # Experimental versions are not allowed (i.e. `v1.2.3-experimental`)
1318 - " !v[0-9]+.[0-9]+.[0-9]+-*"
1419
20+ env :
21+ RELEASE_TAG : ${{ inputs.tag || github.ref_name }}
22+
1523jobs :
1624 build-linux-amd64 :
1725 runs-on : ubuntu-latest
1826 env :
1927 FORCE_COLOR : 1
2028 steps :
2129 - uses : actions/checkout@v6
30+ with :
31+ ref : ${{ env.RELEASE_TAG }}
32+ - uses : crystal-lang/install-crystal@v1
2233 - name : Build and package
2334 run : |
2435 mkdir -p bin
25- # TODO: needs build step
36+ shards build lucky --release --production
2637 sha256sum bin/lucky | awk '{print $1}' > ./bin/checksums.txt
27- tar -czvf lucky-$GITHUB_REF_NAME -linux-amd64.tar.gz -C ./bin .
38+ tar -czvf lucky-$RELEASE_TAG -linux-amd64.tar.gz -C ./bin .
2839 - uses : actions/upload-artifact@v7
2940 with :
3041 name : linux
31- path : lucky-${{ github.ref_name }}-linux-amd64.tar.gz
42+ path : lucky-${{ env.RELEASE_TAG }}-linux-amd64.tar.gz
3243 if-no-files-found : error
3344
3445 build-windows-amd64 :
3546 runs-on : windows-latest
3647 steps :
3748 - uses : actions/checkout@v6
49+ with :
50+ ref : ${{ env.RELEASE_TAG }}
3851 - uses : crystal-lang/install-crystal@v1
3952 - uses : ilammy/msvc-dev-cmd@v1
4053 - name : Build and package
4154 run : |
42- shards build lucky --without-development --no-debug --release --static
43- (Get-FileHash ./bin/lucky).Hash | Out-File ./bin/checksums.txt
44- Compress-Archive -Path ./bin/* -DestinationPath lucky-$env:GITHUB_REF_NAME -windows-amd64.zip
55+ shards build lucky --release --production --static
56+ (Get-FileHash ./bin/lucky.exe ).Hash | Out-File ./bin/checksums.txt
57+ Compress-Archive -Path ./bin/* -DestinationPath lucky-$env:RELEASE_TAG -windows-amd64.zip
4558 - uses : actions/upload-artifact@v7
4659 with :
4760 name : windows
48- path : lucky-${{ github.ref_name }}-windows-amd64.zip
61+ path : lucky-${{ env.RELEASE_TAG }}-windows-amd64.zip
4962 if-no-files-found : error
5063
5164 release :
@@ -55,30 +68,35 @@ jobs:
5568 runs-on : ubuntu-latest
5669 steps :
5770 - uses : actions/checkout@v6
71+ with :
72+ ref : ${{ env.RELEASE_TAG }}
5873 - uses : actions/download-artifact@v8
5974 with :
6075 path : artifacts
6176 - name : Checksums
6277 run : |
6378 cd artifacts
64- sha256sum linux/lucky-$GITHUB_REF_NAME -linux-amd64.tar.gz | awk '{print $1}' > linux/lucky-$GITHUB_REF_NAME -linux-amd64.tar.gz.sha256
65- sha256sum windows/lucky-$GITHUB_REF_NAME -windows-amd64.zip | awk '{print $1}' > windows/lucky-$GITHUB_REF_NAME -windows-amd64.zip.sha256
79+ sha256sum linux/lucky-$RELEASE_TAG -linux-amd64.tar.gz | awk '{print $1}' > linux/lucky-$RELEASE_TAG -linux-amd64.tar.gz.sha256
80+ sha256sum windows/lucky-$RELEASE_TAG -windows-amd64.zip | awk '{print $1}' > windows/lucky-$RELEASE_TAG -windows-amd64.zip.sha256
6681 - name : Release
6782 uses : softprops/action-gh-release@v2
6883 with :
6984 draft : true
7085 fail_on_unmatched_files : true
86+ tag_name : ${{ env.RELEASE_TAG }}
7187 files : |
72- artifacts/linux/lucky-${{ github.ref_name }}-linux-amd64.tar.gz
73- artifacts/linux/lucky-${{ github.ref_name }}-linux-amd64.tar.gz.sha256
74- artifacts/windows/lucky-${{ github.ref_name }}-windows-amd64.zip
75- artifacts/windows/lucky-${{ github.ref_name }}-windows-amd64.zip.sha256
88+ artifacts/linux/lucky-${{ env.RELEASE_TAG }}-linux-amd64.tar.gz
89+ artifacts/linux/lucky-${{ env.RELEASE_TAG }}-linux-amd64.tar.gz.sha256
90+ artifacts/windows/lucky-${{ env.RELEASE_TAG }}-windows-amd64.zip
91+ artifacts/windows/lucky-${{ env.RELEASE_TAG }}-windows-amd64.zip.sha256
7692
7793 homebrew-lucky :
7894 needs : release
7995 runs-on : ubuntu-latest
8096 steps :
8197 - uses : actions/checkout@v6
98+ with :
99+ ref : ${{ env.RELEASE_TAG }}
82100 - name : Generate app token
83101 id : generate-token
84102 uses : actions/create-github-app-token@v3
87105 private-key : ${{ secrets.APP_PRIVATE_KEY }}
88106 - name : Trigger Release Workflow
89107 run : |
90- url_="https://github.com/luckyframework/lucky_cli/archive/refs/tags/${{ github.ref_name }}.zip"
108+ url_="https://github.com/luckyframework/lucky_cli/archive/refs/tags/${{ env.RELEASE_TAG }}.zip"
91109 sha_="$(curl -sL $url_ | sha256sum | awk '{print $1}')"
92110 version_="$(yq '.version' shard.yml)"
93111
@@ -105,6 +123,8 @@ jobs:
105123 runs-on : ubuntu-latest
106124 steps :
107125 - uses : actions/checkout@v6
126+ with :
127+ ref : ${{ env.RELEASE_TAG }}
108128 - name : Generate app token
109129 id : generate-token
110130 uses : actions/create-github-app-token@v3
@@ -113,7 +133,7 @@ jobs:
113133 private-key : ${{ secrets.APP_PRIVATE_KEY }}
114134 - name : Trigger Release Workflow
115135 run : |
116- url_="https://github.com/luckyframework/lucky_cli/releases/download/${{ github.ref_name }}/lucky-${{ github.ref_name }}-windows-amd64.zip"
136+ url_="https://github.com/luckyframework/lucky_cli/releases/download/${{ env.RELEASE_TAG }}/lucky-${{ env.RELEASE_TAG }}-windows-amd64.zip"
117137 sha_="$(curl -sL $url_.sha256)"
118138 version_="$(yq '.version' shard.yml)"
119139
0 commit comments