Skip to content

Commit

Permalink
fix: get version from job output
Browse files Browse the repository at this point in the history
  • Loading branch information
italopessoa committed Oct 16, 2024
1 parent 62d8025 commit a6a5700
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ env:

jobs:
build:
if: false && github.ref_type != 'tag'
if: false
name: Build and analyze
runs-on: windows-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
distribution: 'zulu'

- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0

- name: Cache SonarCloud packages
uses: actions/cache@v4
Expand Down Expand Up @@ -69,15 +69,16 @@ jobs:
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
semantic-release:
needs: build
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
name: Create Semantic Release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
outputs:
version: ${{ steps.semantic-release.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -96,14 +97,19 @@ jobs:
run: npm audit signatures

- name: Release
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
run: |
npx semantic-release
VERSION=$(cat VERSION)
echo "Resolved version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
build-docker-image:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: semantic-release
if: github.ref == 'refs/heads/main' && startsWith(github.ref, 'refs/tags/v')
name: Create Docker image - ${{ github.ref }}
name: Create Docker image
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -113,6 +119,9 @@ jobs:
API_IMAGE_TAG: ${{ fromJson(steps.meta.outputs.json).tags[0] }}

steps:
- name: Extract version
run: echo ${{ needs.semantic-release.outputs.version }}

- name: Checkout repository
uses: actions/checkout@v4

Expand Down

0 comments on commit a6a5700

Please sign in to comment.