Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: cleanup release workflow #218

Merged
merged 8 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/if-nodejs-pr-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#This action is centrally managed in https://github.com/asyncapi/.github/
#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
#It does magic only if there is package.json file in the root of the project
name: PR testing if Node project

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

jobs:
test:
if: github.event.pull_request.draft == false
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check if Node.js project and has package.json
id: packagejson
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
shell: bash
- if: steps.packagejson.outputs.exists == 'true'
name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- if: steps.packagejson.outputs.exists == 'true'
name: Install dependencies
run: npm install --loglevel verbose
- if: steps.packagejson.outputs.exists == 'true'
name: Test
run: npm test
- if: steps.packagejson.outputs.exists == 'true'
name: Run linter
run: npm run lint
63 changes: 63 additions & 0 deletions .github/workflows/if-nodejs-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release

on:
push:
branches:
- master

jobs:

test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check if Node.js project and has package.json
id: packagejson
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
shell: bash
- if: steps.packagejson.outputs.exists == 'true'
name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- if: steps.packagejson.outputs.exists == 'true'
name: Install dependencies
run: npm install
- if: steps.packagejson.outputs.exists == 'true'
name: Run test
run: npm test

release:
needs: test
name: Publish to NPM and GitHub
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check if Node.js project and has package.json
id: packagejson
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
- if: steps.packagejson.outputs.exists == 'true'
name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- if: steps.packagejson.outputs.exists == 'true'
name: Install dependencies
run: npm install
- if: steps.packagejson.outputs.exists == 'true'
name: Release to NPM and GitHub
id: release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_NAME: asyncapi-bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: asyncapi-bot
GIT_COMMITTER_EMAIL: [email protected]
run: npm run release
40 changes: 40 additions & 0 deletions .github/workflows/if-nodejs-version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#This action is centrally managed in https://github.com/asyncapi/.github/
#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
#It does magic only if there is package.json file in the root of the project
name: 'Version bump if Node.js project'

on:
release:
types:
- published

jobs:
version_bump:
name: Generate assets and bump
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Check if Node.js project and has package.json
id: packagejson
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
- if: steps.packagejson.outputs.exists == 'true'
name: Assets generation
run: npm run generate:assets
- if: steps.packagejson.outputs.exists == 'true'
name: Bump version in package.json
# There is no need to substract "v" from the tag as version script handles it
# When adding "bump:version" script in package.json, make sure no tags are added by default (--no-git-tag-version) as they are already added by release workflow
# When adding "bump:version" script in package.json, make sure --allow-same-version is set in case someone forgot and updated package.json manually and we want to avoide this action to fail and raise confusion
run: VERSION=${{github.event.release.tag_name}} npm run bump:version
- if: steps.packagejson.outputs.exists == 'true'
name: Create Pull Request with updated asset files including package.json
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GH_TOKEN }}
commit-message: 'chore(release): ${{github.event.release.tag_name}}'
committer: asyncapi-bot <[email protected]>
author: asyncapi-bot <[email protected]>
title: 'chore(release): ${{github.event.release.tag_name}}'
body: 'Version bump in package.json for release [${{github.event.release.tag_name}}](${{github.event.release.html_url}})'
branch: version-bump/${{github.event.release.tag_name}}
49 changes: 49 additions & 0 deletions .github/workflows/issues-prs-notifications.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#This action is centrally managed in https://github.com/asyncapi/.github/
#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
name: 'Notify slack'

on:
issues:
types:
- opened
pull_request:
types:
- opened

jobs:

issue:
if: github.event_name == 'issues' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
name: On every new issue
runs-on: ubuntu-latest
steps:
- name: Convert markdown to slack markdown for issue
uses: LoveToKnow/[email protected]
id: issuemarkdown
with:
text: "[${{github.event.issue.title}}](${{github.event.issue.html_url}}) \n ${{github.event.issue.body}}"
- name: Send info about issue
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}}
SLACK_TITLE: 🐛 New Issue 🐛
SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}}
MSG_MINIMAL: true

pull_request:
if: github.event_name == 'pull_request' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
name: On every new pull request
runs-on: ubuntu-latest
steps:
- name: Convert markdown to slack markdown for pull request
uses: LoveToKnow/[email protected]
id: prmarkdown
with:
text: "[${{github.event.pull_request.title}}](${{github.event.pull_request.html_url}}) \n ${{github.event.pull_request.body}}"
- name: Send info about pull request
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}}
SLACK_TITLE: 💪 New Pull Request 💪
SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}}
MSG_MINIMAL: true
26 changes: 0 additions & 26 deletions .github/workflows/pull-request-testing.yml

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/release-announcements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#This action is centrally managed in https://github.com/asyncapi/.github/
#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
name: 'Announce releases in different channels'

on:
release:
types:
- published

jobs:

slack:
name: Slack - notify on every release
runs-on: ubuntu-latest
steps:
- name: Convert markdown to slack markdown for issue
uses: LoveToKnow/[email protected]
id: markdown
with:
text: "[${{github.event.release.tag_name}}](${{github.event.release.html_url}}) \n ${{ github.event.release.body }}"
- name: Send info about release to Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASES }}
SLACK_TITLE: Release ${{github.event.release.tag_name}} for ${{github.repository}} is out in the wild 😱💪🍾🎂
SLACK_MESSAGE: ${{steps.markdown.outputs.text}}
MSG_MINIMAL: true

twitter:
name: Twitter - notify on minor and major releases
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Get version of last and previous release
uses: actions/github-script@v3
id: versions
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const query = `query($owner:String!, $name:String!) {
repository(owner:$owner, name:$name){
releases(first: 2, orderBy: {field: CREATED_AT, direction: DESC}) {
nodes {
name
}
}
}
}`;
const variables = {
owner: context.repo.owner,
name: context.repo.repo
};
const { repository: { releases: { nodes } } } = await github.graphql(query, variables);
core.setOutput('lastver', nodes[0].name);
// 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
// We should tweet about the release no matter of the type as it is initial release
if (nodes.length != 1) core.setOutput('previousver', nodes[1].name);
- name: Identify release type
id: releasetype
# if previousver is not provided then this steps just logs information about missing version, no errors
run: echo "::set-output name=type::$(npx -q -p semver-diff-cli semver-diff ${{steps.versions.outputs.previousver}} ${{steps.versions.outputs.lastver}})"
- name: Get name of the person that is behind the newly released version
id: author
run: echo "::set-output name=name::$(git log -1 --pretty=format:'%an')"
- name: Publish information about the release to Twitter # tweet only if detected version change is not a patch
# tweet goes out even if the type is not major or minor but "You need provide version number to compare."
# 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
if: steps.releasetype.outputs.type != 'null' && steps.releasetype.outputs.type != 'patch' # null means that versions are the same
uses: m1ner79/[email protected]
with:
twitter_status: "Release ${{github.event.release.tag_name}} for ${{github.repository}} is out in the wild 😱💪🍾🎂\n\nThank you for the contribution ${{ steps.author.outputs.name }} ${{github.event.release.html_url}}"
twitter_consumer_key: ${{ secrets.TWITTER_CONSUMER_KEY }}
twitter_consumer_secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
twitter_access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
twitter_access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
56 changes: 56 additions & 0 deletions .github/workflows/release-wc-and-playground.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release Web-component and Playground

on:
release:
types:
- published

jobs:

webcomponent:
name: Release Web-component
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install latest version of library in the web-component
run: VERSION=${{github.event.release.tag_name}} npm run install:reactcomp
working-directory: ./web-component
- name: Install dependencies
run: npm install
- name: Release web-component to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./web-component/package.json
access: public

playground:
name: Release Playground
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- name: Use latest version of react component in the playground
run: VERSION=${{github.event.release.tag_name}} npm run install:reactcomp
working-directory: ./playground
- name: Install dependencies
run: npm install
- name: Deploy GH page
uses: JamesIves/[email protected]
with:
ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}
BRANCH: gh-pages
FOLDER: playground/build
GIT_CONFIG_NAME: asyncapi-bot
GIT_CONFIG_EMAIL: [email protected]


Loading