Skip to content

Commit

Permalink
feat(CI/CD): automate changelog creation and update (Lichtblick-Suite#18
Browse files Browse the repository at this point in the history
)

* Automate changelog file update on release using github actions workflows
* Add release instructions to README.me
* Reset changelog.md
* Add pre-commit hook fo Conventional Commits

doc(example-data): Create README.md for example data (Lichtblick-Suite#20)

* Create README.md for example data
* delete outdated example
* add OpenPASS as optional simulator
---------
Signed-off-by: Carlo van Driesten <carlo.van-driesten@bmw.de>

ci(release): remove trigger on PRs from workflow (Lichtblick-Suite#21)

Ci(fix): release pipeline (Lichtblick-Suite#23)

* ci(release): swap direct push on main with a PR

* ci(release): add PAT to main push operation

Update README.md

* add requirement to sign a tag to readme

Signed-off-by: Carlo van Driesten <carlo.van-driesten@bmw.de>

ci(release): attach changelog to release instead of committing to main (Lichtblick-Suite#24)

* ci(release): attach changelog to release instead of committing to main
* ci(release): add PR creation job

fix(ci): release pipeline fix (Lichtblick-Suite#25)

* update to node 18
* remove create pull request for now
---------

Signed-off-by: Carlo van Driesten <carlo.van-driesten@bmw.de>
Co-authored-by: Carlo van Driesten <carlo.van-driesten@bmw.de>

ci: add initial commit history to workflow|bump version to 0.0.2 (Lichtblick-Suite#26)

ci(release): update workflow (Lichtblick-Suite#27)

Ci  release pipeline fix (Lichtblick-Suite#28)

* ci(release): use env variables instead of set-output

* ci(release): update release

Ci  release pipeline fix (Lichtblick-Suite#29)

* ci(release): use env variables instead of set-output

* ci(release): update release

* ci(release): add line seperations to initial commit history in changelog

Ci  release pipeline fix (Lichtblick-Suite#30)

* ci(release): use env variables instead of set-output

* ci(release): update release

* ci(release): fix pipeline workflow

ci: adapt pipeline workflow (Lichtblick-Suite#31)

ci(release): add initial commit history fetch job to pipeline (Lichtblick-Suite#32)

Ci  create pr to update changelog file (Lichtblick-Suite#33)

* ci(release): add PR creation step to update changelog file

* chore(package): bump version to v0.0.3

ci(release): update PR commit message (Lichtblick-Suite#34)

ci(release): remove uppercase start from commit message (Lichtblick-Suite#35)

ci(release): add PAT to PR creation step (Lichtblick-Suite#36)

ci(release): handle staging with create-pull-request action (Lichtblick-Suite#40)

ci(release): add commit step to update-changelog branch (Lichtblick-Suite#42)

ci(release): add branch pull action before commit (Lichtblick-Suite#43)

ci(release): force changes in changelog commit (Lichtblick-Suite#44)

ci(release): specifiy pull reconcilation (Lichtblick-Suite#45)

ci(release): add changes stashing before and after pull (Lichtblick-Suite#46)

Ci  create pr to update changelog file (Lichtblick-Suite#47)

* ci(release): update workflow

* ci(release): add delete branch option

ci(release): update workflow (Lichtblick-Suite#49)

ci(release): update workflow (Lichtblick-Suite#50)

ci(release): update workflow (Lichtblick-Suite#52)

ci(release): update workflow (Lichtblick-Suite#53)

ci(release): split jobs (Lichtblick-Suite#54)

ci(release): preserve state across jobs (Lichtblick-Suite#56)

ci(release): update workflow (Lichtblick-Suite#57)

ci(release): update workflow (#1)

ci(release): update pipeline

ci(release): update pipeline
  • Loading branch information
samikachai committed Dec 17, 2024
1 parent aa2c414 commit 6d2aaac
Show file tree
Hide file tree
Showing 12 changed files with 15,106 additions and 817 deletions.
107 changes: 105 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ name: release

on:
push:
tags: ['v[0-9].[0-9]+.[0-9]+']
tags: ["v[0-9].[0-9]+.[0-9]+"]

permissions:
contents: write
pull-requests: write

jobs:
build_foxe:
Expand All @@ -20,7 +21,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: "18"

- name: Install dependencies
run: npm install
Expand All @@ -34,7 +35,56 @@ jobs:
version=$(node -p "require('./package.json').version")
echo "version=$version" >> $GITHUB_ENV
- name: Update changelog file
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
yarn commitizen init cz-conventional-changelog --save-dev --force --save-exact
HEADER=$(awk '/^---/{exit} {print}' CHANGELOG.md)
yarn conventional-changelog -p angular -o TEMP.md -r 0
echo "$HEADER" > CHANGELOG.md
echo "" >> CHANGELOG.md
cat TEMP.md >> CHANGELOG.md
rm TEMP.md
- name: Fetch initial commit history
id: fetch_initial_commit_history
run: |
INITIAL_COMMIT_HISTORY=$(cat initial_commit_history.md)
echo "INITIAL_COMMIT_HISTORY<<EOF" >> $GITHUB_ENV
echo "$INITIAL_COMMIT_HISTORY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Insert initial commit history
run: |
TARGET_TAG="0.0.1"
FILE="CHANGELOG.md"
INITIAL_COMMIT_HISTORY="${{ env.INITIAL_COMMIT_HISTORY }}"
if grep -q "^## $TARGET_TAG " "$FILE"; then
sed -i "/^## $TARGET_TAG /,/^## /{//!d}" "$FILE"
awk -v content="$INITIAL_COMMIT_HISTORY" -v tag="## $TARGET_TAG " '
BEGIN { found=0 }
$0 ~ tag { print; print content; found=1; next }
{ print }
END { if (!found) print "Tag header not found!" }
' "$FILE" > TEMP.md && mv TEMP.md "$FILE"
echo "Initial commit history inserted under the ## $TARGET_TAG header in $FILE."
else
echo "Tag ## $TARGET_TAG not found in $FILE."
fi
- name: Commit changelog changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add --all
git commit -m "chore: update changelog for $GITHUB_REF"
- name: Create GitHub Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: create_release
uses: actions/create-release@v1
env:
Expand All @@ -46,6 +96,7 @@ jobs:
prerelease: false

- name: Upload Release Asset
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -54,3 +105,55 @@ jobs:
asset_path: lichtblick.asam-osi-converter-${{ env.version }}.foxe
asset_name: lichtblick.asam-osi-converter-${{ env.version }}.foxe
asset_content_type: application/octet-stream

- name: Upload Changelog as a release asset
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./CHANGELOG.md
asset_name: CHANGELOG.md
asset_content_type: text/markdown

- name: Upload CHANGELOG as artifact
uses: actions/upload-artifact@v3
with:
name: changelog
path: ./CHANGELOG.md

create_pull_request:
name: Create Pull Request
needs: build_foxe
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "18"

- name: Install dependencies
run: npm install

- name: Download changelog artifact
uses: actions/download-artifact@v3
with:
name: changelog
path: ./

- name: Create a Pull Request to update the changelog file
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.PAT_TOKEN }}
commit-message: "docs: update CHANGELOG for release"
branch: "update-changelog"
title: "Update CHANGELOG for new release"
body: "This pull request updates the CHANGELOG file with details of the new release."
base: "main"
delete-branch: true
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
Empty file added .husky/pre-commit
Empty file.
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# ASAM OSI Converter version history

## 0.0.1

- Initial release
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,93 @@ yarn run package
```

This command will package the extension into a `.foxe` file in the local directory.

## Contributions and Release Workflow

This guide explains the steps to manage commits, tags, and releases for this project.

---

## **1. Commit Guidelines**

All commits must follow the **Conventional Commits** standard to ensure consistency and changelog generation.

### Commit Message Format:

```
<type>(<scope>): <description>
```

#### Examples:

- `feat: add new feature`
- `fix(auth): resolve a bug`
- `docs: update README.md file`

### Types:

- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation changes
- `style`: Code style changes (e.g., formatting)
- `refactor`: Code restructuring without feature/bug changes
- `test`: Adding or fixing tests
- `chore`: Maintenance tasks
- `ci`: Continuous integration changes

---

## **2. Tagging for Releases**

Tags are used to create release points in the project.

### Steps to Tag a Release:

1. Ensure all changes for the release are committed and pushed to the main branch.
2. Use the following command to create a new tag:

```bash
git tag -s -a v<version> -m "Release v<version>"
```

Example:

```bash
git tag -s -a v1.0.0 -m "ASAM OSI Converter v1.0.0"
```

3. Push the tag to the remote repository:
```bash
git push origin v<version>
```

---

## **3. Creating a GitHub Release**

Once the tag is pushed, create a release on GitHub:

1. Go to the **Releases** section of the repository.
2. Click **Draft a new release**.
3. Select the tag you created (e.g., `v1.0.0`).
4. Fill in the release title and notes. Use the changelog for guidance.
5. Click **Publish Release**.

---

## **4. Automating Releases**

This project includes a GitHub Actions workflow to automate changelog updates and publishing releases. Ensure the workflow is configured correctly by following these steps:

1. Push a tag (e.g., `v1.0.0`) to trigger the workflow.
2. Verify the changelog and release on GitHub.

---

## **5. Troubleshooting**

- **Commit Rejected**: Ensure your commit message follows the Conventional Commits format.
- **Empty Changelog**: Verify that commit messages are properly formatted.
- **Tag Not Found**: Push the tag using `git push origin v<version>`.

For further assistance, contact the repository codeowners.
6 changes: 6 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"header-max-length": [2, "always", 72],
},
};
11 changes: 11 additions & 0 deletions example-data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Create ASAM OSI MCAP files

The [multi trace format definition](https://github.com/OpenSimulationInterface/open-simulation-interface/pull/841) is implemented in the [ASAM OSI Utilities](https://github.com/Lichtblick-Suite/asam-osi-utilities/tree/main/examples) where you can use the `convert_osi2mcap` example to convert a standard compliant `.osi` trace to an mcap trace.
You can use e.g. esmini to create `.osi` trace files.
Take a look at the [OpenMSL actions](https://github.com/openMSL/sl-1-0-sensor-model-repository-template/tree/main/test/integration/003_output_osi_fields) how to run a complete co-simulation.

Another option to create traces is the OpenPASS [gt-gen-simlator](https://gitlab.eclipse.org/eclipse/openpass/gt-gen-simulator).

## Example traces

tbd
Binary file removed example-data/only_osi_topic.mcap
Binary file not shown.
29 changes: 29 additions & 0 deletions initial_commit_history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Initial commit

Update LICENSE

Update README

Create CODEOWNERS

Jest configuration and initial unit tests

Implement TrafficSigns

Improve logic to prevent TrafficSign rerender

Synchronize OSI extension code

Fix trafficsign category modelCache

Traffic Lights Implementation

Create release with artifact on new tag (#3)

Integrate ASAM OSI as Dependency for OSI Ground Truth Extension (#5)

Remove old unneeded manually created types (#9)

Migrate from npm to yarn (#10)

Install @lichtblick/asam-osi-types npm package and update imports. (#16)
Loading

0 comments on commit 6d2aaac

Please sign in to comment.