Skip to content

Commit

Permalink
ci(workflows): reversed pipeline
Browse files Browse the repository at this point in the history
Pipeline now generates version and changelog without release or tag, so repo can update itself first. It is to prevent mismatch in version inside configuration files and boots arduino repo
  • Loading branch information
bigsmalloverall committed Jul 21, 2021
1 parent a230f43 commit 4c0dc83
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions .github/workflows/semantic_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- master
jobs:
semantic-release:
semantic-release-dry-run:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tag_version.outputs.new_tag }}
Expand All @@ -18,19 +18,10 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix:

- name: Create a GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}

repo-self-update:
runs-on: ubuntu-latest
needs: semantic-release
needs: semantic-release-dry-run
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -43,12 +34,12 @@ jobs:
- name: Update package.json version
if: hashFiles('package.json') != ''
run: echo "$( jq '.version = "${{ needs.semantic-release.outputs.version }}"' package.json )" > package.json
run: echo "$( jq '.version = "${{ needs.semantic-release-dry-run.outputs.version }}"' package.json )" > package.json

- name: Update library.properties version
if: hashFiles('library.properties') != ''
run: |
version="${{ needs.semantic-release.outputs.version }}"
version="${{ needs.semantic-release-dry-run.outputs.version }}"
sed -i "s/^\(version\s*=\s*\).*$/\1$version/" "library.properties"
- name: Create changelog.md
Expand All @@ -57,7 +48,7 @@ jobs:

- name: Update changelog.md
run: |
newChangelog="${{ needs.semantic-release.outputs.changelog }}"
newChangelog="${{ needs.semantic-release-dry-run.outputs.changelog }}"
oldChangelog=$(cat changelog.md)
printf "%s%c%s" "$newChangelog" $'\n' "$oldChangelog" >> new_changelog.md
mv -f new_changelog.md changelog.md
Expand All @@ -74,3 +65,16 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

semantic-release:
runs-on: ubuntu-latest
needs: semantic-release-dry-run
steps:
- name: Create a GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.semantic-release-dry-run.outputs.version }}
release_name: Release ${{ needs.semantic-release-dry-run.outputs.version }}
body: ${{ needs.semantic-release-dry-run.outputs.changelog }}

0 comments on commit 4c0dc83

Please sign in to comment.