Debian Codegraph @

.github/workflows/publish.yml

raw symbols SCIP
1 name: Publish
2 on:
3 push:
4 branches: [master]
5 permissions:
6 contents: write
7
8 jobs:
9 publish:
10 name: Publish
11 runs-on: ubuntu-latest
12 steps:
13 - name: Checkout repository
14 uses: actions/checkout@v3
15 - name: Get local crate version
16 id: local-version
17 run: cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version' | echo "VERSION=$(cat)" >> "${GITHUB_OUTPUT}"
18 - name: Get crates.io crate version
19 id: remote-version
20 run: curl 'https://index.crates.io/co/lo/colored' | jq -r '.vers' | tail -n 1 | echo "VERSION=$(cat)" >> "${GITHUB_OUTPUT}"
21 - name: Check if crates.io version is older than local version
22 id: needs-update
23 run: |
24 if ! printf '%s\n' "${{ steps.local-version.outputs.VERSION }}" "${{ steps.remote-version.outputs.VERSION }}" | sort -V | tail -n 1 | grep -Fw "${{ steps.remote-version.outputs.VERSION }}"; then
25 echo "UPDATE=true" >> "${GITHUB_OUTPUT}"
26 else
27 echo "UPDATE=false" >> "${GITHUB_OUTPUT}"
28 fi
29 - name: Install parse-changelog
30 if: steps.needs-update.outputs.UPDATE == 'true'
31 uses: taiki-e/install-action@parse-changelog
32 - name: Create GitHub release
33 if: steps.needs-update.outputs.UPDATE == 'true'
34 run: gh release create "v${{ steps.local-version.outputs.VERSION }}" -t "v${{ steps.local-version.outputs.VERSION }}" -n "$(parse-changelog CHANGELOG.md "${{ steps.local-version.outputs.VERSION }}")"
35 env:
36 GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
37 - name: Publish to crates.io
38 if: steps.needs-update.outputs.UPDATE == 'true'
39 run: cargo publish
40 env:
41 CARGO_REGISTRY_TOKEN: "${{ secrets.CARGO_REGISTRY_TOKEN }}"