Skip to content

Commit

Permalink
update releease workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
juliankrispel committed May 18, 2020
1 parent 2c29622 commit a9b889a
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 8 deletions.
29 changes: 21 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ on:
# Sequence of patterns matched against refs/tags
branches:
- master
# tags:
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Create Release

Expand All @@ -22,11 +20,9 @@ jobs:
run: node scripts/release.js
env:
PACKAGES: core, react
# - name: Print the entry
# run: |
# echo "${{ steps.changelog_entry.outputs.title }}"
# echo "${{ steps.changelog_entry.outputs.version }}"
# echo "${{ steps.changelog_entry.outputs.description }}"
- name: Create Release if does not exist
run: echo "release this"
if: ${{ steps.changelog_reader.outputs.already_released == false }}

# - name: Create Release
# id: create_release
Expand All @@ -38,4 +34,21 @@ jobs:
# release_name: Release ${{ github.ref }}
# body: ${{ steps.changelog_reader.outputs.log_entry }} # This pulls from the GET CHANGELOG ENTRY step above, referencing it's ID to get its outputs object, which include a `log_entry`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
# draft: false
# prerelease: false
# prerelease: false

# - name: npm publish
# run: |
# npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
# cd core
# npm publish
# cd ..
# cd react
# npm publish
# env:
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# - name: Print the entry
# run: |
# echo "${{ steps.changelog_entry.outputs.title }}"
# echo "${{ steps.changelog_entry.outputs.version }}"
# echo "${{ steps.changelog_entry.outputs.description }}"

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": true,
"dependencies": {
"@actions/core": "^1.2.4",
"@actions/github": "^2.2.0",
"@types/jest": "^24.0.17",
"@types/node": "12.0.4",
"@types/react": "^16.8.23",
Expand Down
23 changes: 23 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,42 @@ const github = require('@actions/github');
const fs = require('fs')
const path = require('path')
const packages = process.env.PACKAGES.split(',').map(package => package.trim())
const token = process.env.GITHUB_TOKEN

const octokit = new github.GitHub(token);


async function run() {
const log = await parse('./CHANGELOG.md')


const { data: releases } = await octokit.repos.listReleases({
owner: 'juliankrispel',
repo: 'zettel'
})
console.log({ releases })

const version = log.versions.find(version => version.version != null)
core.setOutput('title', version.title)
core.setOutput('version', version.version)
core.setOutput('description', version.body)
core.setOutput('already_released', false)


packages.forEach(package => {
const packageJson = JSON.parse(fs.readFileSync(path.join('./', package, 'package.json')).toString())
if (packageJson.version !== version.version) {
core.setFailed(`Release failed because version in changelog: ${version.version} isn't the same as version in ${packageJson.name} which is ${packageJson.version}`)
}
})

// check if already released on github
releases.forEach(release => {
if(release.tag_name.includes(version.version)) {
core.setFailed(`Release failed because version in changelog: ${version.version} isn't the same as version in ${packageJson.name} which is ${packageJson.version}`)
core.setOutput('already_released', true)
}
})
}

run()
Loading

0 comments on commit a9b889a

Please sign in to comment.