Skip to content

Commit

Permalink
chore: fully automate releases (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric authored Feb 14, 2022
1 parent 6931e3c commit fbd4450
Showing 1 changed file with 53 additions and 6 deletions.
59 changes: 53 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ concurrency:
cancel-in-progress: true

jobs:
release:
dryrun:
if: ${{ github.ref != 'refs/heads/main' || github.event.inputs.release != 'release' }}
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
Expand All @@ -27,16 +28,62 @@ jobs:
cache: yarn

- name: 📦 Install dependencies
run: yarn install --frozen-lockfile --check-files
run: yarn install --frozen-lockfile

- name: 📋 Dry-running release
if: ${{ github.ref != 'refs/heads/main' || github.event.inputs.release != 'release' }}
run: yarn semantic-release --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}

publish:
if: ${{ github.ref == 'refs/heads/main' && github.event.inputs.release == 'release' }}
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v2

- name: 🏗 Setup Node
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: yarn

- name: 📦 Install dependencies
run: yarn install --frozen-lockfile

- name: 📋 Release code
if: ${{ github.ref == 'refs/heads/main' && github.event.inputs.release == 'release' }}
run: yarn semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}

tags:
needs: publish
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v2

- name: 🏗 Setup Node
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: yarn

- name: 📦 Install dependencies
run: yarn install --frozen-lockfile

- name: 📦 Install semver
run: yarn add --dev semver

- name: 🕵️ Resolve major version
uses: actions/github-script@v6
id: version
with:
result-encoding: string
script: |
const semver = require('semver')
const { version } = require('./package.json')
return semver.major(version)
- name: 📋 Update tags
run: git tag --force v${{ steps.version.outputs.result }} && git push --force --tags

0 comments on commit fbd4450

Please sign in to comment.