Skip to content

Commit

Permalink
feat(release): add release workflow
Browse files Browse the repository at this point in the history
Merge pull request #47 from jbeveland27/feat/release
  • Loading branch information
jbeveland27 authored May 27, 2021
2 parents afc3003 + d4370e0 commit 4c9c81f
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release

on:
push:
branches:
- main

env:
THIRD_PARTY_GIT_AUTHOR_EMAIL: opensource+bot@newrelic.com
THIRD_PARTY_GIT_AUTHOR_NAME: nr-opensource-bot

jobs:
job-generate-release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14

- name: Add plugins for semantic release
run: npm install @semantic-release/git @semantic-release/changelog

- name: Temporarily disable branch protections
id: disable-branch-protection
if: always()
uses: actions/github-script@v1
with:
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
previews: luke-cage-preview
script: |
const result = await github.repos.updateBranchProtection({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
required_status_checks: null,
restrictions: null,
enforce_admins: null,
required_pull_request_reviews: null
})
console.log("Result:", result)
- name: Run semantic-release
env:
# Use nr-opensource-bot for authoring commits done by
# semantic-release (rather than using @semantic-release-bot)
GIT_AUTHOR_NAME: "nr-opensource-bot"
GIT_AUTHOR_EMAIL: "opensource+bot@newrelic.com"
GIT_COMMITTER_NAME: "nr-opensource-bot"
GIT_COMMITTER_EMAIL: "opensource+bot@newrelic.com"
GITHUB_TOKEN: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
run: npx semantic-release

- name: Re-enable branch protections
id: enable-branch-protection
if: always()
uses: actions/github-script@v1
with:
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
previews: luke-cage-preview
script: |
const result = await github.repos.updateBranchProtection({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
required_status_checks: {
strict: true,
contexts: []
},
restrictions: {
"users":[],
"teams":[],
"apps":[]
},
enforce_admins: null,
required_pull_request_reviews: {
dismiss_stale_reviews: true,
required_approving_review_count: 1
}
})
console.log("Result:", result)
17 changes: 17 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", {
"changelogFile": "CHANGELOG.md"
}],
"@semantic-release/github",
["@semantic-release/git", {
"assets": ["CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}]
],
"dryRun": false,
"debug": true
}

0 comments on commit 4c9c81f

Please sign in to comment.