Skip to content

Commit

Permalink
feat: first release
Browse files Browse the repository at this point in the history
**Description:**

This PR introduces [Semantic Release](https://github.com/semantic-release/semantic-release), a tool for automated version management and package publishing. It follows the [Semantic Versioning](http://semver.org/) specification and automates the versioning process to ensure it's consistent and reliable.

**Changes:**

1. **Semantic Release Configuration:** Added a `.releaserc` configuration file for Semantic Release. This file specifies the branches to track and the plugins to use for the semantic release process.

2. **GitHub Actions Workflow:** Updated the `docker-publish.yml` workflow file to include a step for running Semantic Release. This step will automatically determine the next version number, generate release notes, and create a GitHub release.

3. **Package.json:** Updated the `scripts` section of the `package.json` file to include a `semantic-release` script.

4. **Dependencies:** Added `semantic-release` and related plugins as devDependencies in the `package.json` file.

By implementing Semantic Release, we aim to streamline our release process, reduce the possibility of human error, and provide meaningful and consistent release notes for our users. This change should not affect the functionality of the application.
  • Loading branch information
gloaysa committed Mar 16, 2024
1 parent f717e26 commit 1fa096e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 25 deletions.
59 changes: 50 additions & 9 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ on:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-deploy:
build:
name: Release new semantic version
runs-on: ubuntu-latest

outputs:
didRelease: ${{ steps.semver.outputs.new_release_published }}
newVersion: ${{ steps.semver.outputs.new_release_version }}
steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GHCR_PAT }}

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -28,7 +29,47 @@ jobs:
- name: Build application
run: npm run build

- run: npx semantic-release
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: ./build

- name: semantic-release
uses: cycjimmy/semantic-release-action@v4
id: semver
env:
GITHUB_TOKEN: ${{ secrets.GHCR_PAT }}
API_TOKEN: ${{ secrets.GHCR_PAT }}
publish:
name: Build Docker image
needs: build
if: needs.build.outputs.didRelease == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GHCR_PAT }}

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build
path: ./build
- name: Log download path
run: echo ${{ steps.download.outputs.download-path }}
- name: List directory contents
run: ls -la

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./
push: true
tags: ghcr.io/${{ github.repository }}:${{ needs.build.outputs.newVersion }}
37 changes: 21 additions & 16 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{
"branches": ["main"],
plugins: [
['@codedependant/semantic-release-docker', {
dockerTags: ['latest', '{{version}}', '{{major}}-latest', '{{major}}.{{minor}}'],
dockerImage: 'whatsplaying',
dockerFile: 'Dockerfile',
dockerRegistry: 'ghcr.io',
dockerBuildFlags: {
pull: null,
target: 'release'
},
dockerArgs: {
RELEASE_DATE: new Date().toISOString(),
RELEASE_VERSION: '{{next.version}}',
}
}]
"branches": [
{
"name": "main",
"channel": "latest"
},
{
"name": "develop",
"channel": "next"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/npm", {
"npmPublish": false
}],
["@semantic-release/git", {
"assets": ["package.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]"
}],
"@semantic-release/github"
]
}

0 comments on commit 1fa096e

Please sign in to comment.