Skip to content

Commit

Permalink
ci: added semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
glichtner committed May 15, 2024
1 parent 7190234 commit d874aeb
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 76 deletions.
76 changes: 0 additions & 76 deletions .github/workflows/ig-publish.yml

This file was deleted.

152 changes: 152 additions & 0 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Release Workflow

on:
workflow_dispatch:

jobs:
check-release:
runs-on: ubuntu-latest
concurrency: check-release
permissions:
id-token: write
contents: write

outputs:
new_release_published: ${{ steps.semantic_release_version.outputs.new_release_published }}
new_release_version: ${{ steps.semantic_release_version.outputs.new_release_version }}
prerelease: ${{ steps.check-prerelease.outputs.prerelease }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"

- name: Install dependencies
run: |
sudo snap install yq
npm install @semantic-release/changelog @semantic-release/github
- name: Semantic Release (Determine new version)
id: semantic_release_version
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/github
dry_run: true
ci: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Output new release version
run: |
echo Version: ${{ steps.semantic_release_version.outputs.new_release_version }}
echo new_release_published: ${{ steps.semantic_release_version.outputs.new_release_published }}
- name: Check pre-release
id: check-prerelease
run: |
if [[ "${{ steps.semantic_release_version.outputs.new_release_version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "prerelease=false" >> $GITHUB_OUTPUT
else
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Echo Prelease
run: |
echo pre-release: ${{ steps.check-prerelease.outputs.prerelease }}
perform-release:
needs: check-release
if: needs.check-release.outputs.new_release_published == 'true'
runs-on: ubuntu-latest

permissions:
id-token: write
contents: write

outputs:
new_release_published: ${{ steps.semantic_release.outputs.new_release_published }}
new_release_version: ${{ steps.semantic_release.outputs.new_release_version }}
new_release_git_tag: ${{ steps.semantic_release.outputs.new_release_git_tag }}
prerelease: ${{ needs.check-release.outputs.prerelease }}
ig_canonical: ${{ steps.yaml-data.outputs.canonical }}
ig_id: ${{ steps.yaml-data.outputs.id }}
ig_asset_filename: ${{ steps.generate-asset-filename.outputs.ig_asset_filename }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"

- name: Install dependencies
run: |
sudo snap install yq
npm install @semantic-release/changelog @semantic-release/github
- name: Update sushi-config.yaml with new version
run: |
yq eval '.version = "${{ needs.check-release.outputs.new_release_version }}"' -i sushi-config.yaml
# read id, version and canonical from sushi-config.yaml
- name: Read YAML file
id: yaml-data
run: |
VERSION=$(yq eval '.version' sushi-config.yaml)
ID=$(yq eval '.id' sushi-config.yaml)
CANONICAL=$(yq eval '.canonical' sushi-config.yaml)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "id=$ID" >> $GITHUB_OUTPUT
echo "canonical=$CANONICAL" >> $GITHUB_OUTPUT
- name: Generate asset filename
id: generate-asset-filename
run: echo "ig_asset_filename=${{ steps.yaml-data.outputs.id }}-${{ needs.check-release.outputs.new_release_version }}.tgz" >> $GITHUB_OUTPUT

# display outputs from read-yaml action
- name: Display read-yaml output
run: |
echo "id: ${{ steps.yaml-data.outputs.id }}"
echo "target url: ${{ steps.yaml-data.outputs.canonical }}"
echo "version: ${{ steps.yaml-data.outputs.version }}"
echo "asset filename: ${{ steps.generate-asset-filename.outputs.ig_asset_filename }}"
- name: Run the IG publisher
uses: docker://hl7fhir/ig-publisher-base:latest
with:
args: ./run-ig-publisher.sh

- name: Move package.tgz to output directory
run: |
mkdir -p dist/
mv ./output/package.tgz dist/${{ steps.generate-asset-filename.outputs.ig_asset_filename }}
- name: Deploy to GitHub Pages
if: needs.check-release.outputs.prerelease == 'false'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./output
force_orphan: true

- name: Semantic Release (Create release)
id: semantic_release
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/github
ci: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
branches:
- '+([0-9])?(.{+([0-9]),x}).x'
- master
- main
- next
- next-major
- name: beta
prerelease: true
- name: alpha
prerelease: true
- name: "+(feat|fix|perf|chore|ci|docs|refactor|test|style)/**"
prerelease: "${name.split('/').slice(0, 2).join('-').toLowerCase()}"
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/changelog"
-
- "@semantic-release/github"
- assets:
- "dist/**"

0 comments on commit d874aeb

Please sign in to comment.