Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/build-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,22 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.302'
- name: Extract version
- name: Determine version from ref
id: version
run: echo "cli_version=$(grep -oP '(?<=<Version>).*?(?=</Version>)' version.props)" >> $GITHUB_OUTPUT
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
else
VERSION="0.0.0"
fi
echo "cli_version=$VERSION" >> "$GITHUB_OUTPUT"
cat <<EOF > version.props
<Project>
<PropertyGroup>
<Version>$VERSION</Version>
</PropertyGroup>
</Project>
EOF
- name: Restore
run: |
dotnet restore OrgCodingHoursCLI/OrgCodingHoursCLI.csproj --locked-mode
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI
on:
push:
branches: [main]
tags:
- "v*"
pull_request:
branches: [main]
workflow_call:
Expand Down
29 changes: 5 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Release

on:
push:
branches: [main]
tags:
- "v*"

permissions:
contents: write
Expand Down Expand Up @@ -48,32 +49,12 @@ jobs:
run: docker build --build-arg CLI_VERSION=${{ needs.build_cli.outputs.cli_version }} -t ghcr.io/$REPO_LC:${{ needs.build_cli.outputs.cli_version }} .
- name: Push image
run: docker push ghcr.io/$REPO_LC:${{ needs.build_cli.outputs.cli_version }}

tag_release:
create_release:
needs: [publish_cli, docker]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --tags
- name: Read version
id: version
run: |
VERSION=$(grep -oP '(?<=<Version>)[^<]+' version.props)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check tag
id: check
run: |
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Create tag and release
if: steps.check.outputs.exists == 'false'
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag "v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"
gh release create "v${{ steps.version.outputs.version }}" --generate-notes
run: gh release create "${{ github.ref_name }}" --generate-notes
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ docker run --rm \
ghcr.io/labview-community-ci-cd/org-coding-hours-action:v0.1.0
```

Replace `v0.1.0` with the version defined in `version.props`.
Replace `v0.1.0` with the desired release tag.

#### Run inside a workflow

Expand Down
3 changes: 2 additions & 1 deletion version.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.1.0</Version>
<!-- Version is populated from the Git tag during build -->
<Version>0.0.0</Version>
</PropertyGroup>
</Project>