-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Implementing Automated Version Release and Publish to PlatformIO (#…
…27) * ci: Implementing Automated Version Release and Publish to PlatformIO docs: Assuring conventional commits - This PR changed: [prlint.yml]: Validates every PR against Conventional Commits to guarantee a healthy release and publish. [release.yml]: Automates releasing a new version including all the necessary steps using semantic-release action. Must pass prlint and tests CIs. [publish.yml]: Automates publishing the new released version to PlatformIO registry and update versions in library.json and library.properties files. Depends on [release.yml]. [CONTRIBUTING.md]: Added note for new contributors about conventional commit message. resolves issue #5 * fix(ci): Library Release Versions Manipulation Improvement and Refactoring Pushing New Release Versions
- Loading branch information
1 parent
4eace4c
commit 3b5b048
Showing
6 changed files
with
119 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Pull Request Message Validation | ||
on: pull_request | ||
|
||
jobs: | ||
prlint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Validate Pull Request | ||
uses: amannn/action-semantic-pull-request@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,73 @@ | ||
name: PlatformIO Publish Release | ||
name: Publish to PlatformIO | ||
|
||
on: | ||
release: | ||
types: [released] | ||
workflow_call: | ||
|
||
jobs: | ||
release: | ||
pio-publish: | ||
runs-on: ubuntu-latest | ||
env: | ||
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} | ||
name: Publish a new Release to PlatformIO | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.9' | ||
python-version: "3.9" | ||
- name: Install PlatformIO Core | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install platformio | ||
- name: Publish Release | ||
- name: Install jq for handling JSON data | ||
run: | | ||
sudo apt update | ||
sudo apt install -y jq | ||
- name: Update Library Metadata and Configurations | ||
run: | | ||
LATEST_TAG=$(git describe --tags --abbrev=0) | ||
LIB_V=$(jq -r .version library.json) | ||
PROPS_V=$(cat library.properties | grep -oP version=\K.*) | ||
if [ $LIB_V = $LATEST_TAG ] || [ $PROPS_V = $LATEST_TAG ]; then | ||
exit 1 | ||
fi | ||
set -e | ||
sed -i -E "s/(version=).*/\1${LATEST_TAG}/" library.properties | ||
echo ✅ Successfully Modified release tag in library.json file... | ||
jq ".version = \"${LATEST_TAG}\"" library.json > temp.json && mv temp.json library.json | ||
echo ✅ Successfully Modified release tag in library.properties file... | ||
- name: Publish to PlatformIO | ||
env: | ||
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} | ||
run: | | ||
pio package publish --no-interactive --type library | ||
echo 👍 Successfully published to PlatformIO | ||
update-lib-versions: | ||
runs-on: ubuntu-latest | ||
name: Update versions in library.json and library.properties | ||
needs: pio-publish | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
- name: Update library versions | ||
run: | | ||
LATEST_TAG=$(git describe --tags --abbrev=0) | ||
set -e | ||
sed -i -E "s/(version=).*/\1${LATEST_TAG}/" library.properties | ||
jq ".version = \"${LATEST_TAG}\"" library.json > temp.json && mv temp.json library.json | ||
- name: Push to main branch using PAT | ||
env: | ||
PAT: ${{ secrets.CI_PAT }} # new fine-grained PAT with contents = rw | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
git remote set-url origin https://x-access-token:${{ env.PAT }}@github.com/${{ github.repository }} | ||
git stash | ||
git pull origin main | ||
git stash pop | ||
git add library.json library.properties | ||
git commit -m "Automated update: Update library.json library.properties" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Version Release | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["PlatformIO Unit Tests"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
gh-release: | ||
name: Release a new Version | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: latest | ||
- name: GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
npm init -y | ||
npm install --save-dev \ | ||
semantic-release \ | ||
@semantic-release/commit-analyzer \ | ||
@semantic-release/release-notes-generator \ | ||
@semantic-release/git \ | ||
@semantic-release/changelog \ | ||
@semantic-release/github | ||
npx [email protected] | ||
echo 👍 Successfully released a new version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"branches": [ | ||
"main" | ||
], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/git", | ||
"@semantic-release/changelog", | ||
"@semantic-release/github" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters