Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
SizzinSeal committed Dec 30, 2024
1 parent 85f0707 commit 1330848
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Add Template to Pull Request
on:
workflow_run:
workflows: ['Build Template']
workflows: ['PROS Build Template']
types: [completed]
jobs:
pr_comment:
Expand Down
109 changes: 8 additions & 101 deletions .github/workflows/pros-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Template
name: PROS Build Template

on:
push:
Expand All @@ -11,109 +11,16 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Get short SHA
id: short-sha
run: |
if [ $ACTION = opened ]; then
# we have to get the head sha directly from the pr api, because github silly ig
echo "then"
sha=$(wget -O- --quiet https://api.github.com/repos/LemLib/LemLog/pulls/$PR_NUM | jq -r .head.sha | head -c 6)
else
echo "else"
sha=$(echo $SHA | head -c 6)
fi
echo "sha=$sha" >> $GITHUB_OUTPUT
env:
SHA: ${{ github.event.after }} # this isn't present for pr opened events
ACTION: ${{github.event.action}}
PR_NUM: ${{github.event.number}}

- name: Set short SHA
run: echo $SHA
env:
SHA: ${{ steps.short-sha.outputs.sha }}

- name: Install ARM Toolchain
uses: fiam/arm-none-eabi-gcc@v1
with:
release: "10-2020-q4"

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: PIP Installer
uses: BSFishy/pip-action@v1
with:
packages: pros-cli

- name: Testing PROS Install
run: pros --version

- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v4

- name: Get version number
id: version
run: |
version=$(awk -F'=' '/^VERSION:=/{print $2}' Makefile)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Get Template Postfix
id: template-postfix
run: |
echo postfix="$VER+$SHA" >> "$GITHUB_OUTPUT"
env:
SHA: ${{ steps.short-sha.outputs.sha }}
VER: ${{ steps.version.outputs.version }}

- name: Get Template Name
id: template-name
run: |
echo name=$TEMPLATE_NAME@$POSTFIX >> "$GITHUB_OUTPUT"
env:
POSTFIX: ${{ steps.template-postfix.outputs.postfix }}
TEMPLATE_NAME: ${{ github.event.repository.name }}

- name: Update version in Makefile
run: sed -i "s/^VERSION:=.*\$/VERSION:=$POSTFIX/" Makefile
env:
POSTFIX: ${{ steps.template-postfix.outputs.postfix }}

- name: Build PROS Project
run: make clean quick -j

- name: Create template
run: pros make template

- name: Create template folder
run: mkdir -p template/include/lemlog/

- name: Copy LICENSE and README.md into template
run: cp {LICENSE,README.md} template/include/lemlog/

- name: Append GitHub link to README.md
run: echo "\n## [Github link](${{github.server_url}}/${{github.repository}})" >> template/include/lemlog/README.md

- name: Fix relative Github links in README.md
run: perl -i -pe 's@(?<=[^/])(docs/assets/.*?)(?=[")])@${{github.server_url}}/${{github.repository}}/blob/master/$1?raw=true@g' template/include/lemlog/README.md

- name: Unzip Template
uses: montudor/[email protected]
with:
args: unzip "${{steps.template-name.outputs.name}}.zip" -d template

- name: Create VERSION file
run: echo $POSTFIX > template/include/lemlog/VERSION
env:
POSTFIX: ${{ steps.template-postfix.outputs.postfix }}
- name: Run LemLib/pros-build
id: test
uses: LemLib/[email protected]

- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.template-name.outputs.name }}
path: "template/*"
retention-days: 89
name: ${{ steps.test.outputs.name }}
path: ${{ github.workspace }}/template/*

0 comments on commit 1330848

Please sign in to comment.