18
18
push :
19
19
tags :
20
20
- " v*"
21
+
21
22
env :
22
23
CRATE_NAME : git-dive
24
+
25
+ # We need this to be able to create releases.
26
+ permissions :
27
+ contents : write
28
+
23
29
jobs :
24
30
create-release :
25
31
name : create-release
26
32
runs-on : ubuntu-latest
27
33
outputs :
28
- upload_url : ${{ steps.release.outputs.upload_url }}
29
- release_version : ${{ env.RELEASE_VERSION }}
34
+ tag : ${{ env.TAG }}
30
35
steps :
31
- - name : Get the release version from the tag
32
- shell : bash
33
- if : env.RELEASE_VERSION == ''
34
- run : |
35
- # See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
36
- echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
37
- echo "version is: ${{ env.RELEASE_VERSION }}"
38
36
- name : Checkout repository
39
37
uses : actions/checkout@v4
40
38
with :
41
39
fetch-depth : 1
40
+ - name : Get the release version from the tag
41
+ if : env.TAG == ''
42
+ run : echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV
43
+ - name : Show the tag
44
+ run : |
45
+ echo "tag is: $TAG"
42
46
- name : Generate Release Notes
43
47
run : |
44
- ./.github/workflows/release-notes.py --tag ${{ env.RELEASE_VERSION }} --output notes-${{ env.RELEASE_VERSION }}.md
45
- cat notes-${{ env.RELEASE_VERSION }}.md
48
+ ./.github/workflows/release-notes.py --tag ${{ env.TAG }} --output notes-${{ env.TAG }}.md
49
+ cat notes-${{ env.TAG }}.md
46
50
- name : Create GitHub release
47
- id : release
48
- uses : actions/create-release@v1
49
51
env :
50
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
51
- with :
52
- tag_name : ${{ env.RELEASE_VERSION }}
53
- release_name : ${{ env.RELEASE_VERSION }}
54
- body_path : notes-${{ env.RELEASE_VERSION }}.md
52
+ GH_TOKEN : ${{ github.token }}
53
+ run : gh release create $TAG --verify-tag --draft --title $TAG --notes-file notes-${{ env.TAG }}.md
55
54
build-release :
56
55
name : build-release
57
56
needs : create-release
68
67
os : macos-latest
69
68
rust : stable
70
69
target : x86_64-apple-darwin
70
+ - build : macos-aarch64
71
+ os : macos-latest
72
+ rust : stable
73
+ target : aarch64-apple-darwin
71
74
- build : win-msvc
72
75
os : windows-2019
73
76
rust : stable
@@ -93,27 +96,40 @@ jobs:
93
96
- name : Build archive
94
97
shell : bash
95
98
run : |
96
- outdir="./target/${{ env.TARGET_DIR }}/release"
97
- staging="${{ env.CRATE_NAME }}-${{ needs.create-release.outputs.release_version }}-${{ matrix.target }}"
98
- mkdir -p "$staging"/{complete, doc}
99
+ outdir="./target/${{ matrix.target }}/release"
100
+ staging="${{ env.BIN_NAME }}-${{ needs.create-release.outputs.tag }}-${{ matrix.target }}"
101
+ mkdir -p "$staging"/doc
99
102
cp {README.md,LICENSE-*} "$staging/"
100
103
cp {CHANGELOG.md,docs/*} "$staging/doc/"
101
104
if [ "${{ matrix.os }}" = "windows-2019" ]; then
102
- cp "target/${{ matrix.target }}/release/git-dive.exe" "$staging/"
105
+ cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" "$staging/"
106
+ ls -l "$staging"
103
107
cd "$staging"
104
108
7z a "../$staging.zip" .
105
109
echo "ASSET=$staging.zip" >> $GITHUB_ENV
106
110
else
107
- cp "target/${{ matrix.target }}/release/git-dive" "$staging/"
111
+ cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" "$staging/"
112
+ ls -l "$staging"
108
113
tar czf "$staging.tar.gz" -C "$staging" .
109
114
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
110
115
fi
111
116
- name : Upload release archive
112
-
113
117
env :
114
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
118
+ GH_TOKEN : ${{ github.token }}
119
+ shell : bash
120
+ run : |
121
+ tag="${{ needs.create-release.outputs.tag }}"
122
+ gh release upload "$tag" ${{ env.ASSET }}
123
+ publish-release :
124
+ name : Publish Release
125
+ needs : [create-release, build-release]
126
+ runs-on : ubuntu-latest
127
+ steps :
128
+ - name : Checkout repository
129
+ uses : actions/checkout@v4
115
130
with :
116
- upload_url : ${{ needs.create-release.outputs.upload_url }}
117
- asset_path : ${{ env.ASSET }}
118
- asset_name : ${{ env.ASSET }}
119
- asset_content_type : application/octet-stream
131
+ fetch-depth : 1
132
+ - name : Publish Release
133
+ env :
134
+ GH_TOKEN : ${{ github.token }}
135
+ run : gh release edit "${{ needs.create-release.outputs.tag }}" --draft=false
0 commit comments