-
-
Notifications
You must be signed in to change notification settings - Fork 38
88 lines (75 loc) · 2.76 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Publish Library to PIO Registry
on:
workflow_dispatch:
inputs:
part_to_increment:
description: "Part to increment (1 for major, 2 for minor, 3 for patch)"
required: true
jobs:
publish:
name: Prepare Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install click
pip install --upgrade platformio
- name: Login to PlatformIO
run: |
pio account login -u "${{ secrets.PIO_USERNAME }}" -p "${{ secrets.PIO_PASSWORD }}"
- name: Update Version
env:
PART_TO_INCREMENT: ${{ github.event.inputs.part_to_increment }}
run: |
chmod +x version
./version "$PART_TO_INCREMENT"
echo "UPDATED_VERSION=$(grep "version=" library.properties | cut -d'=' -f2)" >> $GITHUB_ENV
- name: Authenticate as GitHub App
id: auth
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Commit changes
env:
GH_TOKEN: ${{ steps.auth.outputs.token }}
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git add .
git commit -m "Update version to $UPDATED_VERSION"
git push https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git master
- name: Create Tag
if: ${{ env.UPDATED_VERSION != '' }}
run: |
git tag -a "${{ env.UPDATED_VERSION }}" -m "Tagging version ${{ env.UPDATED_VERSION }}"
git push https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git "${{ env.UPDATED_VERSION }}"
- name: Publish to PlatformIO
id: publish
run: yes y | pio pkg publish
continue-on-error: true
- name: Revert push and delete tag if publish fails
if: failure()
env:
GH_TOKEN: ${{ steps.auth.outputs.token }}
run: |
git reset --hard HEAD~1
git push https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git +HEAD
git tag -d ${{ github.ref_name }}
- name: Create GitHub Release
if: success()
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: LcdMenu v${{ github.ref_name }}
draft: true
prerelease: false