1+ name : Tag, Release, & Publish
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+
8+ jobs :
9+ deploy :
10+ name : Deploy
11+ runs-on : ubuntu-latest
12+ steps :
13+ # Checkout updated source code
14+ - uses : actions/checkout@v2
15+
16+ # If the version has changed, create a new git tag for it.
17+ - name : Tag
18+ id : autotagger
19+ uses : butlerlogic/action-autotag@master
20+ env :
21+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
22+
23+ # The remaining steps all depend on whether or not
24+ # a new tag was created. There is no need to release/publish
25+ # updates until the code base is in a releaseable state.
26+
27+ # If the new version/tag is a pre-release (i.e. 1.0.0-beta.1), create
28+ # an environment variable indicating it is a prerelease.
29+ - name : Pre-release
30+ if : steps.autotagger.outputs.tagname != ''
31+ run : |
32+ if [[ "${{ steps.autotagger.output.version }}" == *"-"* ]]; then echo "::set-env IS_PRERELEASE=true";else echo "::set-env IS_PRERELEASE=''";fi
33+
34+ # Create a github release
35+ # This will create a snapshot of the module,
36+ # available in the "Releases" section on Github.
37+ - name : Release
38+ id : create_release
39+ if : steps.autotagger.outputs.tagname != ''
40+ uses : actions/create-release@v1.0.0
41+ env :
42+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
43+ with :
44+ tag_name : ${{ steps.autotagger.outputs.tagname }}
45+ release_name : ${{ steps.autotagger.outputs.tagname }}
46+ body : ${{ steps.autotagger.outputs.tagmessage }}
47+ draft : false
48+ prerelease : env.IS_PRERELEASE != ''
49+
50+ # Use this action to publish a single module to npm.
51+ - name : Publish
52+ id : publish_npm
53+ if : steps.autotagger.outputs.tagname != ''
54+ uses : author/action-publish@master
55+ env :
56+ REGISTRY_TOKEN : ${{ secrets.REGISTRY_TOKEN }}
57+
58+ - name : Rollback Release
59+ if : failure() && steps.create_release.outputs.id != ''
60+ uses : author/action-rollback@stable
61+ with :
62+ tag : ${{ steps.autotagger.outputs.tagname }}
63+ env :
64+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments