87 lines
3.4 KiB
YAML
87 lines
3.4 KiB
YAML
name: Release New Version
|
|
|
|
# Based on: https://github.blog/2021-12-16-5-automations-every-developer-should-be-running/
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Largest semver bump of new version (major / minor / patch)"
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- patch
|
|
- minor
|
|
- major
|
|
|
|
jobs:
|
|
bump-version:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# Check out the content (source branch). Use a deploy key so that
|
|
# when we push changes, it will trigger the release workflow
|
|
# run that runs on: tag. (Using the GitHub token would
|
|
# not run the workflow to prevent infinite recursion.)
|
|
- name: Check out source
|
|
uses: actions/checkout@v2
|
|
with:
|
|
ssh-key: ${{ secrets.DEPLOY_KEY }}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: "16"
|
|
|
|
- name: Setup Git
|
|
run: |
|
|
git config user.name 'release-bot'
|
|
git config user.email 'adamtuttlecodes@gmail.com'
|
|
|
|
- name: bump version
|
|
run: npm version ${{ github.event.inputs.version }}
|
|
|
|
- name: get-npm-version
|
|
id: package-version
|
|
uses: martinbeentjes/npm-get-version-action@master
|
|
|
|
- name: Update version in api.cfc
|
|
run: |
|
|
cat core/api.cfc | sed 's/local\._taffy\.version = \"[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\"/local._taffy.version = "${{ steps.package-version.outputs.current-version }}"/gi' > core/api.new.cfc
|
|
rm -f core/api.cfc
|
|
mv core/api.new.cfc core/api.cfc
|
|
git add core/api.cfc
|
|
git commit --amend --no-edit
|
|
|
|
- name: Cut a docs file for the new release
|
|
run: |
|
|
cat docs/@next.md | sed 's/@version@/${{ steps.package-version.outputs.current-version }}/gi' > docs/${{ steps.package-version.outputs.current-version }}.md
|
|
git add docs/${{ steps.package-version.outputs.current-version }}.md
|
|
cat docs/readme.md | sed 's/\<\!--new_docs_links_here--\>/\<\!--new_docs_links_here--\>\n\n- \[\v${{ steps.package-version.outputs.current-version }}]\(${{ steps.package-version.outputs.current-version }}.md\)/g' > docs/readme-next.md
|
|
rm -f docs/readme.md
|
|
mv docs/readme-next.md docs/readme.md
|
|
git add docs/readme.md
|
|
git commit --amend --no-edit
|
|
|
|
- name: Push latest version
|
|
run: git push origin main --follow-tags
|
|
|
|
- name: Create Release Notes
|
|
uses: actions/github-script@v4.0.2
|
|
with:
|
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
script: |
|
|
await github.request(`POST /repos/${{ github.repository }}/releases`, {
|
|
tag_name: "v${{ steps.package-version.outputs.current-version }}",
|
|
generate_release_notes: true
|
|
});
|
|
|
|
- name: Tweet-trigger-publish-release
|
|
uses: mugi111/tweet-trigger-release@v1.1
|
|
with:
|
|
consumer_key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
|
|
consumer_secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
|
|
access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN }}
|
|
access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
|
|
tweet_body: "🍬 Taffy Version ${{steps.package-version.outputs.current-version}} was just released! https://github.com/atuttle/Taffy/releases/tag/v${{ steps.package-version.outputs.current-version }}"
|