1+ on :
2+ push :
3+ tags :
4+ - ' v*' # Run when tag matches v*, i.e. v1.0, v20.15.10
5+
6+ name : Release
7+
8+ env :
9+ RELEASE_BIN : jfmt
10+ RELEASE_DIR : artifacts
11+ GITHUB_REF : ' ${{ github.ref }}'
12+ MACOS_TARGET : x86_64-apple-darwin
13+ LINUX_AMD64_TARGET : x86_64-unknown-linux-musl
14+ LINUX_ARM64_TARGET : aarch64-unknown-linux-musl
15+
16+ # Space separated paths to include in the archive.
17+ RELEASE_ADDS : README.md LICENSE
18+
19+ jobs :
20+ build :
21+ name : Build artifacts
22+ runs-on : ${{ matrix.os }}
23+ strategy :
24+ matrix :
25+ include :
26+ - target : x86_64-unknown-linux-musl
27+ os : ubuntu-latest
28+ rust : stable
29+ - target : aarch64-unknown-linux-musl
30+ os : ubuntu-latest
31+ rust : stable
32+ - target : x86_64-apple-darwin
33+ os : macos-latest
34+ rust : stable
35+
36+ steps :
37+ - uses : actions/checkout@v3
38+ - uses : dtolnay/rust-toolchain@stable
39+ with :
40+ toolchain : ${{ matrix.rust }}
41+
42+ - name : Query version number
43+ id : get_version
44+ shell : bash
45+ run : |
46+ echo "using version tag ${GITHUB_REF:10}"
47+ echo ::set-output name=version::"${GITHUB_REF:10}"
48+
49+ - name : Install C compilation tooling (Linux)
50+ if : matrix.os == 'ubuntu-latest'
51+ run : |
52+ sudo apt-get update -y
53+ sudo apt-get install clang gcc-aarch64-linux-gnu musl-tools -y
54+
55+ - name : Install p7zip (MacOS)
56+ if : matrix.os == 'macos-latest'
57+ run : brew install p7zip
58+
59+ - name : Add rustup target
60+ run : rustup target add ${{ matrix.target }}
61+
62+ - uses : taiki-e/install-action@v2
63+ with :
64+ tool : cross
65+
66+ - name : Build
67+ run : cross build --release --target ${{ matrix.target }}
68+
69+ - name : Create artifact directory
70+ run : |
71+ mkdir ${{ env.RELEASE_DIR }}
72+ mkdir -p ${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}
73+
74+ - name : Move binaries (Linux/MacOS)
75+ if : matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
76+ run : |
77+ mv ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}/${{ env.RELEASE_BIN }}
78+ mv ${{ env.RELEASE_ADDS }} ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}
79+
80+ - name : Create tarball
81+ shell : bash
82+ run : 7z a -ttar -so -an ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }} | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz
83+
84+ - name : Upload Zip
85+ uses : actions/upload-artifact@v1
86+ with :
87+ name : ${{ matrix.target }}
88+ path : ./${{ env.RELEASE_DIR }}
89+
90+ release :
91+ name : GitHub Release
92+ needs : build
93+ runs-on : ubuntu-latest
94+ steps :
95+ - name : Query version number
96+ id : get_version
97+ shell : bash
98+ run : |
99+ echo "using version tag ${GITHUB_REF:10}"
100+ echo ::set-output name=version::"${GITHUB_REF:10}"
101+
102+ - name : Create Release
103+ id : create_release
104+ uses : actions/create-release@v1
105+ env :
106+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
107+ with :
108+ tag_name : ${{ steps.get_version.outputs.VERSION }}
109+ release_name : ${{ steps.get_version.outputs.VERSION }}
110+
111+ - name : Download Linux amd64 tarball
112+ uses : actions/download-artifact@v2
113+ with :
114+ name : ${{ env.LINUX_AMD64_TARGET }}
115+
116+ - name : Download Linux arm64 tarball
117+ uses : actions/download-artifact@v2
118+ with :
119+ name : ${{ env.LINUX_ARM64_TARGET }}
120+
121+ - name : Download MacOS tarball
122+ uses : actions/download-artifact@v2
123+ with :
124+ name : ${{ env.MACOS_TARGET }}
125+
126+ - name : Release Linux amd64 tarball
127+ uses : actions/upload-release-asset@v1
128+ env :
129+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
130+ with :
131+ upload_url : ${{ steps.create_release.outputs.upload_url }}
132+ asset_path : ./jfmt-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_AMD64_TARGET }}.tar.gz
133+ asset_content_type : application/gzip
134+ asset_name : jfmt-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_AMD64_TARGET }}.tar.gz
135+
136+ - name : Release Linux arm64 tarball
137+ uses : actions/upload-release-asset@v1
138+ env :
139+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
140+ with :
141+ upload_url : ${{ steps.create_release.outputs.upload_url }}
142+ asset_path : ./jfmt-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_ARM64_TARGET }}.tar.gz
143+ asset_content_type : application/gzip
144+ asset_name : jfmt-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_ARM64_TARGET }}.tar.gz
145+
146+ - name : Release MacOS tarball
147+ uses : actions/upload-release-asset@v1
148+ env :
149+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
150+ with :
151+ upload_url : ${{ steps.create_release.outputs.upload_url }}
152+ asset_path : ./jfmt-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.tar.gz
153+ asset_content_type : application/gzip
154+ asset_name : jfmt-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.tar.gz
0 commit comments