1
+ # This action is centrally managed in https://github.com/asyncapi/.github/
2
+ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo
3
+ name : ' Announce releases in different channels'
4
+
5
+ on :
6
+ release :
7
+ types :
8
+ - published
9
+
10
+ jobs :
11
+
12
+ slack :
13
+ name : Slack - notify on every release
14
+ runs-on : ubuntu-latest
15
+ steps :
16
+ - name : Convert markdown to slack markdown for issue
17
+ uses :
LoveToKnow/[email protected]
18
+ id : markdown
19
+ with :
20
+ text : " [${{github.event.release.tag_name}}](${{github.event.release.html_url}}) \n ${{ github.event.release.body }}"
21
+ - name : Send info about release to Slack
22
+ uses : rtCamp/action-slack-notify@v2
23
+ env :
24
+ SLACK_WEBHOOK : ${{ secrets.SLACK_RELEASES }}
25
+ SLACK_TITLE : Release ${{github.event.release.tag_name}} for ${{github.repository}} is out in the wild 😱💪🍾🎂
26
+ SLACK_MESSAGE : ${{steps.markdown.outputs.text}}
27
+ MSG_MINIMAL : true
28
+
29
+ twitter :
30
+ name : Twitter - notify on minor and major releases
31
+ runs-on : ubuntu-latest
32
+ steps :
33
+ - name : Checkout repo
34
+ uses : actions/checkout@v2
35
+ - name : Get version of last and previous release
36
+ uses : actions/github-script@v3
37
+ id : versions
38
+ with :
39
+ github-token : ${{ secrets.GITHUB_TOKEN }}
40
+ script : |
41
+ const query = `query($owner:String!, $name:String!) {
42
+ repository(owner:$owner, name:$name){
43
+ releases(first: 2, orderBy: {field: CREATED_AT, direction: DESC}) {
44
+ nodes {
45
+ name
46
+ }
47
+ }
48
+ }
49
+ }`;
50
+ const variables = {
51
+ owner: context.repo.owner,
52
+ name: context.repo.repo
53
+ };
54
+ const { repository: { releases: { nodes } } } = await github.graphql(query, variables);
55
+ core.setOutput('lastver', nodes[0].name);
56
+ // In case of first release in the package, there is no such thing as previous error, so we set info about previous version only once we have it
57
+ // We should tweet about the release no matter of the type as it is initial release
58
+ if (nodes.length != 1) core.setOutput('previousver', nodes[1].name);
59
+ - name : Identify release type
60
+ id : releasetype
61
+ # if previousver is not provided then this steps just logs information about missing version, no errors
62
+ run : echo "::set-output name=type::$(npx -q -p semver-diff-cli semver-diff ${{steps.versions.outputs.previousver}} ${{steps.versions.outputs.lastver}})"
63
+ - name : Get name of the person that is behind the newly released version
64
+ id : author
65
+ run : echo "::set-output name=name::$(git log -1 --pretty=format:'%an')"
66
+ - name : Publish information about the release to Twitter # tweet only if detected version change is not a patch
67
+ # tweet goes out even if the type is not major or minor but "You need provide version number to compare."
68
+ # it is ok, it just means we did not identify previous version as we are tweeting out information about the release for the first time
69
+ if : steps.releasetype.outputs.type != 'null' && steps.releasetype.outputs.type != 'patch' # null means that versions are the same
70
+
71
+ with :
72
+ twitter_status : " Release ${{github.event.release.tag_name}} for ${{github.repository}} is out in the wild 😱💪🍾🎂\n\n Thank you for the contribution ${{ steps.author.outputs.name }} ${{github.event.release.html_url}}"
73
+ twitter_consumer_key : ${{ secrets.TWITTER_CONSUMER_KEY }}
74
+ twitter_consumer_secret : ${{ secrets.TWITTER_CONSUMER_SECRET }}
75
+ twitter_access_token_key : ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
76
+ twitter_access_token_secret : ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
0 commit comments