@@ -14,44 +14,51 @@ jobs:
1414 include :
1515 - os : ubuntu-latest
1616 target : x86_64-unknown-linux-musl
17- archive : tar.gz
1817 - os : windows-latest
1918 target : x86_64-pc-windows-msvc
20- archive : zip
2119 steps :
2220 - uses : actions/checkout@v3
21+
2322 - uses : actions-rs/toolchain@v1
2423 with :
2524 profile : minimal
2625 toolchain : stable
2726 target : ${{ matrix.target }}
2827 override : true
28+
2929 - name : Cache dependencies
3030 uses : Swatinem/rust-cache@v2
31+
3132 - name : Build
3233 run : cargo build --release --locked --verbose --target ${{ matrix.target }}
33- - name : Pack for Linux
34- if : matrix.os == 'ubuntu-latest'
35- env :
36- RELEASE_NAME : dotter-${{ matrix.target }}
37- run : |
38- mkdir $RELEASE_NAME
39- cp -r target/${{ matrix.target }}/release/dotter -t $RELEASE_NAME
40- cp -r completions -t $RELEASE_NAME
41- tar -zcvf $RELEASE_NAME.${{ matrix.archive }} -C $RELEASE_NAME .
42- - name : Pack for Windows
43- if : matrix.os == 'windows-latest'
34+
35+ - name : Pack completions
36+ if : matrix.os == 'ubuntu-latest' # Runs only once
37+ run : zip -r completions.zip completions
38+
39+ - name : Upload asset on Linux
40+ uses : softprops/action-gh-release@v1
4441 env :
45- RELEASE_NAME : dotter-${{ matrix.target }}
46- run : |
47- New-Item -ItemType Directory -Path ${env:RELEASE_NAME}
48- Copy-Item -Path "target\${{ matrix.target }}\release\dotter.exe" -Destination ${env:RELEASE_NAME}
49- Copy-Item -Path "completions" -Destination ${env:RELEASE_NAME} -Recurse
50- Compress-Archive -Path "${env:RELEASE_NAME}\*" -DestinationPath "${env:RELEASE_NAME}.${{ matrix.archive }}" -Force
51- - name : Upload asset
42+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
43+ if : startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest'
44+ with :
45+ files : |
46+ target/${{ matrix.target }}/release/dotter
47+ completions.zip
48+
49+ - name : Upload asset on Windows
5250 uses : softprops/action-gh-release@v1
5351 env :
5452 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55- if : startsWith(github.ref, 'refs/tags/')
53+ if : startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest'
5654 with :
57- files : dotter-${{ matrix.target }}.${{ matrix.archive }}
55+ files : target/${{ matrix.target }}/release/dotter.exe
56+
57+ cargo-publish :
58+ runs-on : ubuntu-latest
59+ steps :
60+ - uses : actions/checkout@v3
61+ - run : cargo login ${CRATES_IO_TOKEN}
62+ env :
63+ CRATES_IO_TOKEN : ${{ secrets.CRATES_IO_TOKEN }}
64+ - run : cargo publish
0 commit comments