4242 name : Lints
4343 runs-on : ubuntu-latest
4444 env :
45- RUSTFLAGS : " -Dwarnings"
45+ RUSTFLAGS : ' -Dwarnings'
4646 steps :
4747 - name : Checkout sources
4848 uses : actions/checkout@v2
@@ -52,118 +52,3 @@ jobs:
5252
5353 - name : Run cargo clippy
5454 run : cargo clippy --all-targets --all-features
55-
56- release :
57- runs-on : macos-latest
58- needs :
59- - test
60- - lints
61- - check
62- outputs :
63- new_version : ${{ steps.check_for_version_changes.outputs.new_version }}
64- changed : ${{ steps.check_for_version_changes.outputs.changed }}
65- if : github.ref == 'refs/heads/main'
66- steps :
67- - uses : actions/checkout@v3
68- with :
69- # https://stackoverflow.com/questions/65944700/how-to-run-git-diff-in-github-actions
70- # TLDR – By default this action fetches no history.
71- # We need a bit of history to be able to check if we've recently updated the version in Cargo.toml
72- fetch-depth : 2
73- - name : Toolchain info
74- run : |
75- cargo --version --verbose
76- rustc --version
77- cargo clippy --version
78- - name : Build
79- run : cargo build --release --target aarch64-apple-darwin --target x86_64-apple-darwin
80- - name : Check for version changes in Cargo.toml
81- id : check_for_version_changes
82- run : |
83- # When there are no changes, VERSION_CHANGES will be empty
84- # Without the echo, this command would exit with a 1, causing the GitHub Action to fail
85- # Instead, we want it to succeed, but just evaluate `changed=false` in the other branch of the conditional
86- VERSION_CHANGES=$(git diff HEAD~1 HEAD Cargo.toml | grep "\+version" || echo "")
87- if [[ -n $VERSION_CHANGES ]]; then
88- NEW_VERSION=$(echo $VERSION_CHANGES | awk -F'"' '{print $2}')
89- echo "changed=true" >> $GITHUB_OUTPUT
90- echo "new_version=v$NEW_VERSION" >> $GITHUB_OUTPUT
91- else
92- echo "changed=false" >> $GITHUB_OUTPUT
93- fi
94-
95- - name : Create GitHub Release if current commit has updated the version in Cargo.toml
96- if : steps.check_for_version_changes.outputs.changed == 'true'
97- run : |
98- gh release create ${{steps.check_for_version_changes.outputs.new_version}} --target "${{ github.sha }}" --generate-notes
99- env :
100- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
101- upload-mac-universal-bin :
102- needs : release
103- runs-on : macos-latest
104- if : ${{needs.release.outputs.new_version}}
105- steps :
106- - uses : actions/checkout@v3
107- - name : Build
108- run : cargo build --release --target aarch64-apple-darwin --target x86_64-apple-darwin
109-
110- - name : Upload mac universal binary
111- run : |
112- # This combines the intel and m1 binaries into a single binary
113- lipo -create -output target/pks target/aarch64-apple-darwin/release/pks target/x86_64-apple-darwin/release/pks
114-
115- # Creates artifact for homebrew. -C means run from `target` directory
116- tar -czf target/pks-mac.tar.gz -C target pks
117-
118- # This tarball is a binary that is executable
119- gh release upload $NEW_VERSION target/pks-mac.tar.gz
120-
121- env :
122- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
123- NEW_VERSION : ${{ needs.release.outputs.new_version }}
124-
125- upload-linux-bin :
126- needs : release
127- if : ${{needs.release.outputs.new_version}}
128- runs-on : ubuntu-latest
129- steps :
130- - uses : actions/checkout@v4
131- - name : Update local toolchain
132- run : |
133- cargo install cross
134- - name : Build linux binaries
135- run : |
136- cross build --release --target x86_64-unknown-linux-gnu
137- cross build --release --target aarch64-unknown-linux-gnu
138- - name : Upload linux binaries
139- run : |
140- tar -czf target/x86_64-unknown-linux-gnu.tar.gz -C target/x86_64-unknown-linux-gnu/release pks
141- tar -czf target/aarch64-unknown-linux-gnu.tar.gz -C target/aarch64-unknown-linux-gnu/release pks
142- gh release upload $NEW_VERSION target/x86_64-unknown-linux-gnu.tar.gz
143- gh release upload $NEW_VERSION target/aarch64-unknown-linux-gnu.tar.gz
144- env :
145- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
146- NEW_VERSION : ${{ needs.release.outputs.new_version }}
147-
148- generate-dotslash-files :
149- name : Generating and uploading DotSlash files
150- needs :
151- - release
152- - upload-linux-bin
153- - upload-mac-universal-bin
154- if : success() && ${{needs.release.outputs.new_version}}
155- runs-on : ubuntu-latest
156-
157- steps :
158- - uses : facebook/dotslash-publish-release@v1
159- # This is necessary because the action uses
160- # `gh release upload` to publish the generated DotSlash file(s)
161- # as part of the release.
162- env :
163- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
164- with :
165- # Additional file that lives in your repo that defines
166- # how your DotSlash file(s) should be generated.
167- config : .github/workflows/dotslash-config.json
168- # Tag for the release to target.
169- tag : ${{ needs.release.outputs.new_version }}
0 commit comments