Skip to content

Commit

Permalink
ci: unite publish and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
igboyes committed Nov 14, 2024
1 parent 881755d commit f707939
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 97 deletions.
69 changes: 34 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,18 @@ name: ci
on:
pull_request:
branches:
- "*"
- "main"
push:
branches:
- "main"

env:
IMAGE_NAME: virtool/iimi
REGISTRY: ghcr.io

jobs:
commitlint:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Lint
uses: wagoid/commitlint-github-action@v5
test:
runs-on: ubuntu-22.04
steps:
- name: Setup Docker
uses: docker/setup-buildx-action@v3
- name: Checkout
uses: actions/checkout@v4
- name: Build
id: build
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
target: test
- name: Test
run: docker run --rm -t ${{ steps.build.outputs.imageid }} pytest --proc 3
release:
runs-on: ubuntu-22.04
needs: [commitlint]
if: github.event_name == 'push'
steps:
- name: Checkout
Expand All @@ -49,14 +24,38 @@ jobs:
with:
node-version: 20
- name: Install semantic-release
run: npm i semantic-release@v23.0.0 conventional-changelog-conventionalcommits@7.0.2
run: npm i semantic-release@v23.0.0 @semantic-release/exec@v6.0.3 conventional-changelog-conventionalcommits@7.0.2
- name: Release
id: release
env:
GITHUB_USERNAME: ${{ secrets.GH_USERNAME }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
VERSION=$(npx semantic-release --dry-run | grep 'Published version' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
echo "::set-output name=version::$VERSION"
- name: Publish
run: echo ${{ steps.release.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
ghcr:
runs-on: ubuntu-22.04
if: github.repository_owner == 'Virtool' && github.event_name == 'push' && needs.release.outputs.git-tag != ''
needs: [release]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.git-tag }}
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
context: git
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
- name: Build and Push
id: push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
40 changes: 0 additions & 40 deletions .github/workflows/publish.yaml

This file was deleted.

54 changes: 32 additions & 22 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
{
"branches": ["main"],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
},
[
"@semantic-release/github",
{
"failComment": false
}
]
],
"repositoryUrl": "https://github.com/virtool/workflow-iimi.git",
"tagFormat": "${version}"
}
"branches":[
"main"
],
"plugins":[
[
"@semantic-release/commit-analyzer",
{
"preset":"conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset":"conventionalcommits"
}
],
[
"@semantic-release/github",
{
"failComment":false
}
],
[
"@semantic-release/exec",
{
"successCmd":"echo \"git-tag=${nextRelease.gitTag}\" >> $GITHUB_OUTPUT"
}
]
],
"repositoryUrl":"https://github.com/virtool/workflow-iimi.git",
"tagFormat":"${version}"
}

0 comments on commit f707939

Please sign in to comment.