fix: . #3
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
name: "Linuxfabrik: Versioning" | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
versioning: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.next_version }} | |
new_release: ${{ steps.version.outputs.new_release }} | |
steps: | |
- name: "Checkout Repository" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Required for full commit history | |
- name: "Set up Node.js" | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: "Install Dependencies" | |
run: npm install -g semantic-release @semantic-release/git @semantic-release/changelog | |
- name: "Determine Next Version" | |
id: version | |
run: | | |
NEXT_VERSION=$(npx semantic-release --dry-run | grep "nextRelease.version" | awk -F'"' '{print $4}') | |
if [ -z "$NEXT_VERSION" ]; then | |
echo "new_release=false" >> $GITHUB_ENV | |
else | |
echo "next_version=$NEXT_VERSION" >> $GITHUB_ENV | |
echo "$NEXT_VERSION" > version.txt | |
echo "new_release=true" >> $GITHUB_ENV | |
fi | |
- name: "Commit and Push Version File" | |
if: env.new_release == 'true' | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add version.txt | |
git commit -m "chore(version): bump to ${{ env.next_version }}" | |
git push | |
- name: "Create Git Tag for Release" | |
if: env.new_release == 'true' | |
run: | | |
git tag "v${{ env.next_version }}" | |
git push origin "v${{ env.next_version }}" | |
- name: "Upload Version File as Artifact" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: version | |
path: version.txt | |