Skip to content

Commit

Permalink
ci: add semantic-release config
Browse files Browse the repository at this point in the history
  • Loading branch information
glichtner committed May 28, 2024
1 parent 5923469 commit 3366bc6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 25 deletions.
46 changes: 21 additions & 25 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:

- name: Install dependencies
run: |
sudo snap install yq
npm install @semantic-release/changelog @semantic-release/github
- name: Semantic Release (Determine new version)
Expand Down Expand Up @@ -103,36 +102,33 @@ jobs:
id: read_package_data
run: |
PACKAGE_ID=$(jq -r '.["package-id"]' package-list.json)
echo "package_id=$PACKAGE_ID" >> $GITHUB_ENV
echo "::set-output name=package_id::$PACKAGE_ID"
echo "package_id=$PACKAGE_ID" >> $GITHUB_OUTPUT
FHIR_VERSION=$(jq -r --arg version "${{ needs.check-release.outputs.last_release_version }}" '.list[] | select(.version == $version) | .fhirversion' package-list.json)
echo "fhir_version=$FHIR_VERSION" >> $GITHUB_ENV
echo "::set-output name=fhir_version::$FHIR_VERSION"
echo "fhir_version=$FHIR_VERSION" >> $GITHUB_OUTPUT
- name: Display package_read output
run: |
echo "package-id: ${{ steps.read_package_data.outputs.package_id }}"
echo "fhir-version: ${{ steps.read_package_data.outputs.fhir_version }}"
- name: Read and update package-list.json
run: |
# First, mark the last version as not current
jq --arg version "${{ needs.check-release.outputs.last_release_version }}" '.list[] |= (select(.version == $version) | .current = false)' package-list.json | \
# Then, add the new version as current
jq --arg version "${{ needs.check-release.outputs.new_release_version }}" --arg date "$(date -u +'%Y-%m-%d')" --arg package_id "${{ steps.read_package_data.outputs.package_id }}" '.list += [{
"version": $version,
"path": "https://github.com/CEOsys/ig-template-ceosys/releases/download/v$version/package.tar.gz",
"status": "release",
"sequence": "Publications",
"fhirversion": "${{ steps.read_package_data.outputs.fhir_version }}",
"desc": "$package_id $version",
"date": $date,
"current": true
}]' > updated-package-list.json
# Replace the original file with the updated one
mv updated-package-list.json package-list.json
- name: Read and update package-list.json
run: |
# First, mark the last version as not current
jq --arg version "${{ needs.check-release.outputs.last_release_version }}" '.list[] |= (select(.version == $version) | .current = false)' package-list.json | \
# Then, add the new version as current
jq --arg version "${{ needs.check-release.outputs.new_release_version }}" --arg date "$(date -u +'%Y-%m-%d')" --arg package_id "${{ steps.read_package_data.outputs.package_id }}" '.list += [{
"version": $version,
"path": "https://github.com/CEOsys/ig-template-ceosys/releases/download/v$version/package.tar.gz",
"status": "release",
"sequence": "Publications",
"fhirversion": "${{ steps.read_package_data.outputs.fhir_version }}",
"desc": "$package_id $version",
"date": $date,
"current": true
}]' > updated-package-list.json
# Replace the original file with the updated one
mv updated-package-list.json package-list.json
- name: Commit and push updated package-list.json
run: |
Expand All @@ -149,7 +145,7 @@ jobs:
- name: Move package.tgz to output directory
run: |
mkdir -p dist/
tar -czf dist/${{ steps.generate-asset-filename.outputs.ig_asset_filename }} --exclude='.git' .
tar -czf ./dist/${{ steps.generate-asset-filename.outputs.ig_asset_filename }} --exclude='.git' .
- name: Semantic Release (Create release)
id: semantic_release
Expand Down
22 changes: 22 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
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/**"
11 changes: 11 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @type {import('semantic-release').GlobalConfig}
*/
module.exports = {
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
};

0 comments on commit 3366bc6

Please sign in to comment.