File tree Expand file tree Collapse file tree 2 files changed +34
-23
lines changed
Expand file tree Collapse file tree 2 files changed +34
-23
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,39 @@ on: [push]
44
55jobs :
66 build :
7-
87 runs-on : ubuntu-latest
9-
108 steps :
11- - uses : actions/checkout@v1
12- - name : Build
13- run : cargo build --verbose
14- - name : Run tests
15- run : cargo test --verbose
9+ - uses : actions/checkout@v1
10+ - name : Build
11+ run : cargo build --all-targets --verbose
12+ - name : Run tests
13+ run : cargo test --verbose
14+ release :
15+ runs-on : ubuntu-latest
16+ needs : build
17+ if : startsWith(github.ref, 'refs/tags/')
18+ steps :
19+ - uses : actions/checkout@v1
20+ - name : Get the changelog
21+ id : get_changes
22+ run : |
23+ changelog=$(sed '/^## '"${GITHUB_REF#refs/tags/}"'.*/,/^## .*/!d;//d' CHANGELOG)
24+ changelog="${changelog//'%'/'%25'}"
25+ changelog="${changelog//$'\n'/'%0A'}"
26+ changelog="${changelog//$'\r'/'%0D'}"
27+ echo "::set-output name=changelog::${changelog}"
28+ - name : Create Release
29+ id : create_release
30+ uses : actions/create-release@latest
31+ env :
32+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
33+ with :
34+ tag_name : ${{ github.ref }}
35+ release_name : ${{ github.ref }}
36+ body : " ${{ steps.get_changes.outputs.changelog }}"
37+ draft : false
38+ prerelease : true
39+ - name : Publish
40+ env :
41+ CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_TOKEN }}
42+ run : cargo publish --verbose
Original file line number Diff line number Diff line change @@ -11,14 +11,6 @@ echo -e "\\n# Checking version number\\n"
1111git fetch
1212git tag --list | grep -q " ${version} " && echo " Error: Git tag ${version} already exists" && exit 1
1313
14- echo -e " \\ n# Checking GitHub credentials\\ n"
15- [[ -n ${GITHUB_TOKEN+x} ]] || (echo " Error: GITHUB_TOKEN variable not set" && exit 1)
16- curl --fail --silent --output /dev/null -H " Authorization: token ${GITHUB_TOKEN} " https://api.github.com/user
17-
18- echo -e " \\ n# Checking crates.io credentials\\ n"
19- [[ -f ~ /.cargo/credentials ]] || (echo " Error: crates.io credentials not present" && exit 1)
20- cargo publish --dry-run --quiet
21-
2214echo -e " \\ n# Updating version number in files\\ n"
2315sed --in-place " s/version = \" .*\" /version = \" ${version} \" /" Cargo.toml
2416sed --in-place " s/## Unreleased/## Unreleased\\ n\\ n## ${version} - ${date} /" CHANGELOG
@@ -27,16 +19,8 @@ echo -e "\\n# Adding to Git\\n"
2719git add Cargo.toml CHANGELOG
2820git commit -m " Update version numbers for ${version} "
2921
30- echo -e " \\ n# Publishing crate\\ n"
31- cargo publish
32-
3322echo -e " \\ n# Pushing to Git\\ n"
3423git tag " ${version} "
3524git push origin --tags
3625
37- echo -e " \\ n# Publishing GitHub release\\ n"
38- changes=$( sed ' /^## ' " ${version} " ' .*/,/^## .*/!d;//d' CHANGELOG)
39- changes=$( echo " ${changes} " | awk ' {printf "%s\\n", $0}' )
40- curl -H " Authorization: token ${GITHUB_TOKEN} " -d ' {"tag_name": "' " ${version} " ' ", "name": "' " ${version} " ' ", "body": "' " ${changes} " ' "}' https://api.github.com/repos/milliams/plotlib/releases | jq
41-
4226echo -e " \\ n# Success ✓"
You can’t perform that action at this time.
0 commit comments