Skip to content

Commit

Permalink
fix(publish release): using mathieudutour/github-tag-action in releas…
Browse files Browse the repository at this point in the history
…e.yml

Now the tag info is retrieved by a dry run of the mathieudutour/github-tag-action that not creates any tag in the end term

The version placeholder has been shorten too
  • Loading branch information
Supermanuu committed Aug 9, 2024
1 parent 72698d3 commit 0d97efc
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:

jobs:

generate-release-first:
uses: ./.github/workflows/release.yml
# generate-release-first: # Not needed for now because any push to main will trigger a build
# uses: ./.github/workflows/release.yml

publish:
runs-on: ubuntu-latest
Expand All @@ -22,6 +22,7 @@ jobs:
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
create_annotated_tag: true

- name: Download artifact
id: download-artifact
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
name: release

on:
push:
branches:
- main
pull_request:
branches: [ "main" ]
workflow_call:
branches:
- main
workflow_call: # Needed in order to be called from other pipeline
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: # Needed to get git version
fetch-depth: 0
fetch-tags: true

- name: Bump version without pushing tag
id: tag
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true # Avoids git tag creation in this run

- name: Generate user guide and adsd it to the release
run: docker compose up doc && mv _doc release

- name: Set Git version
run: docker compose up version
env:
GIT_VERSION_STRING: ${{ steps.tag.outputs.new_tag }}

- name: Generate gerbers, schema, images...
uses: INTI-CMNB/KiBot@v1.7.0
Expand Down
2 changes: 1 addition & 1 deletion BatterySwitcher.kicad_pcb
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@
(layer "Edge.Cuts")
(uuid "9a64e326-5d6b-4b22-8367-a8eb7b1a7ad0")
)
(gr_text "${PROJECTNAME}\nvXX.XX.XX-XXX-XXXXXXXX"
(gr_text "${PROJECTNAME}\nvXX.XX.XXX"
(at 139.8 65.7 0)
(layer "F.SilkS")
(uuid "2ad5bbb7-322f-4463-8520-e3b805a9120d")
Expand Down
2 changes: 1 addition & 1 deletion BatterySwitcher.kicad_sch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(uuid "fff52d9c-2593-4d64-8717-f098392b56b0")
(paper "A4")
(title_block
(rev "vXX.XX.XX-XXX-XXXXXXXX")
(rev "vXX.XX.XXX")
)
(lib_symbols
(symbol "Samacsys:53047-0210"
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# TO DO

* fix closed PR name
* clean!
13 changes: 7 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ services:
bash -c '
set -e -o pipefail
VERSIONED_FILES="BatterySwitcher.kicad_pcb BatterySwitcher.kicad_sch"
if [[ "$(git rev-parse --abbrev-ref HEAD)" =~ release/* ]]; then
GIT_VERSION_STRING=$(git rev-parse --abbrev-ref HEAD | sed "s+release/++g")
else
GIT_VERSION_STRING=$(git describe --tags)
if [ -z "$GIT_VERSION_STRING" ]; then
echo GIT_VERSION_STRING env variable has not been setted
exit 1
fi
echo Applying version "$$GIT_VERSION_STRING"
if ! grep "vXX.XX.XX-XXX-XXXXXXXX" $$VERSIONED_FILES > /dev/null; then
if ! grep "vXX.XX.XXX" $$VERSIONED_FILES > /dev/null; then
echo "No version string found!"
exit 1
fi
for file in $$VERSIONED_FILES; do
sed -i "s/vXX.XX.XX-XXX-XXXXXXXX/$$GIT_VERSION_STRING/g" $$file
sed -i "s/vXX.XX.XXX/$$GIT_VERSION_STRING/g" $$file
done
'
environment:
GIT_VERSION_STRING: ${GIT_VERSION_STRING:-}

0 comments on commit 0d97efc

Please sign in to comment.