Skip to content

Commit

Permalink
add new workflow files / update ecocode-rule-spec / update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
dedece35 committed Dec 29, 2023
1 parent 36351eb commit 0a092bb
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 1 deletion.
91 changes: 91 additions & 0 deletions .github/workflows/_BACKUP_manual_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Manual Release
on:
workflow_dispatch:
inputs:
confirmeRelease:
description: 'Confirm manual release creation (by typing "true") ? ----- WARNING : check version (in pom.xml files) and release notes (in CHANGELOG.md file) before confirm'
default: 'false'
jobs:
checks:
name: Requirements
if: github.event.inputs.confirmeRelease == 'true'
runs-on: ubuntu-latest
steps:
- name: Check user permissions
uses: 74th/[email protected]
with:
users: dedece35,glalloue,jhertout,jules-delecour-dav,olegoaer,zippy1978
build:
name: Build And Release
needs: checks
runs-on: ubuntu-latest
permissions: write-all
outputs:
last_tag: ${{ steps.export_last_tag.outputs.last_tag }}
upload_url: ${{ steps.export_upload_url.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Change commiter
run: |
git config user.name 'github-actions[bot]'
git config user.email ''
- name: Maven release
run: mvn release:prepare -B -ff -DtagNameFormat=@{project.version}
- name: Maven release clean
run: mvn release:clean
- name: Get last TAG
run: echo "LAST_TAG=$(git tag --sort=-version:refname | head -n 1)" >> $GITHUB_ENV
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v1
- name: Checkout tag "${{ env.LAST_TAG }}"
uses: actions/checkout@v3
with:
ref: ${{ env.LAST_TAG }}
- name: Build project
run: mvn -e -B clean package -DskipTests
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.LAST_TAG }}
release_name: Release ${{ env.LAST_TAG }}
draft: false
prerelease: false
body: ${{ steps.extract-release-notes.outputs.release_notes }}
- name: Export plugin Jar files
id: export_jar_files
uses: actions/upload-artifact@v3
with:
name: ecocode-plugins
path: lib
- name: Export LAST_TAG
id: export_last_tag
run: echo "last_tag=${{ env.LAST_TAG }}" >> $GITHUB_OUTPUT
- name: Export UPLOAD_URL
id: export_upload_url
run: echo "upload_url=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_OUTPUT
upload-java:
name: Upload Java Plugin
runs-on: ubuntu-latest
needs: build
steps:
- name: Import plugin JAR files
id: import_jar_files
uses: actions/download-artifact@v3
with:
name: ecocode-plugins
path: lib
- name: Upload Release Asset - Java Plugin
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{needs.build.outputs.upload_url}}
asset_path: lib/ecocode-java-plugin-${{ needs.build.outputs.last_tag }}.jar
asset_name: ecocode-java-plugin-${{ needs.build.outputs.last_tag }}.jar
asset_content_type: application/zip
80 changes: 80 additions & 0 deletions .github/workflows/build_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
# template source: https://github.com/bretfisher/docker-build-workflow/blob/main/templates/call-docker-build.yaml
name: Docker Build

on:
push:
branches:
- main
tags:
- '*'
# pull_request:
# branches:
# - main

env:
# github.repository as <account>/<repo>
# IMAGE_NAME: sonarqube-ecocode
# IMAGES: |
# ghcr.io/${{ github.repository_owner }}/sonarqube-ecocode
IMAGE_NAME: sonarqube-ecocode-java
IMAGES: |
ghcr.io/${{ github.repository_owner }}/sonarqube-ecocode-java
jobs:
Build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: ${{ env.IMAGES }}
flavor: |
latest=auto
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=semver,event=tag,pattern={{version}}
type=semver,event=tag,pattern={{major}}.{{minor}}
type=semver,event=tag,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Publish image
id: push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
pull: true
cache-to: type=gha,mode=max
cache-from: type=gha,mode=max
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Update ecocode-rules-specifications to 1.4.4

### Deleted

[unreleased]: https://github.com/green-code-initiative/ecoCode-java/compare/v1.5.0...HEAD
Expand Down
10 changes: 10 additions & 0 deletions _TODOs_DDC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# IDEAS

.. to tranform into issues ?

- [IN PROGRESS] check `pom.xml` dependencies (usefulness, scope, versions)
- [DONE] first clean, check scopes, factorization
- check usefulness
- upgrade versions
- enable github `dependabot` to create automatically PR with version upgrades of dependencides (when all dependencies will be ok)
- ménage dans les branches de dev (local et remote)
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<google.re2j>1.7</google.re2j>

<!-- temporary version waiting for real automatic release in ecocode repository -->
<ecocode-rules-specifications.version>0.0.10</ecocode-rules-specifications.version>
<ecocode-rules-specifications.version>1.4.4</ecocode-rules-specifications.version>

</properties>

Expand Down

0 comments on commit 0a092bb

Please sign in to comment.