|
15 | 15 | issues: write # to be able to comment on released issues |
16 | 16 | pull-requests: write # to be able to comment on released pull requests |
17 | 17 | id-token: write # to enable use of OIDC for npm provenance |
| 18 | + packages: write # to push Docker images to GHCR |
| 19 | + outputs: |
| 20 | + version: ${{ steps.release.outputs.version }} |
| 21 | + released: ${{ steps.release.outputs.released }} |
18 | 22 | steps: |
19 | 23 | - uses: actions/checkout@v5 |
20 | 24 | - uses: actions/setup-node@v5 |
|
28 | 32 | run: npx vitest run tests/integration |
29 | 33 | env: |
30 | 34 | HEVY_API_KEY: ${{ secrets.HEVY_API_KEY }} |
31 | | - - run: npm run release |
| 35 | + - name: Store initial version |
| 36 | + id: initial_version |
| 37 | + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT |
| 38 | + |
| 39 | + - name: Release |
| 40 | + id: release_step |
| 41 | + run: npm run release |
32 | 42 | env: |
33 | 43 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
34 | 44 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 45 | + |
| 46 | + - name: Check if release was created |
| 47 | + id: release |
| 48 | + run: | |
| 49 | + NEW_VERSION=$(node -p "require('./package.json').version") |
| 50 | + if [ "$NEW_VERSION" != "${{ steps.initial_version.outputs.version }}" ]; then |
| 51 | + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 52 | + echo "released=true" >> $GITHUB_OUTPUT |
| 53 | + echo "Release created: $NEW_VERSION" |
| 54 | + else |
| 55 | + echo "released=false" >> $GITHUB_OUTPUT |
| 56 | + echo "No release created" |
| 57 | + fi |
| 58 | + env: |
| 59 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 60 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 61 | + |
| 62 | + docker-release: |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: release |
| 65 | + if: needs.release.outputs.released == 'true' |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Checkout repository |
| 69 | + uses: actions/checkout@v5 |
| 70 | + |
| 71 | + - name: Set up Docker Buildx |
| 72 | + uses: docker/setup-buildx-action@v3 |
| 73 | + |
| 74 | + - name: Log in to GitHub Container Registry |
| 75 | + uses: docker/login-action@v3 |
| 76 | + with: |
| 77 | + registry: ghcr.io |
| 78 | + username: ${{ github.actor }} |
| 79 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + |
| 81 | + - name: Extract metadata |
| 82 | + id: meta |
| 83 | + uses: docker/metadata-action@v5 |
| 84 | + with: |
| 85 | + images: ghcr.io/${{ github.repository }} |
| 86 | + tags: | |
| 87 | + type=semver,pattern={{version}},value=${{ needs.release.outputs.version }} |
| 88 | + type=semver,pattern={{major}}.{{minor}},value=${{ needs.release.outputs.version }} |
| 89 | + type=semver,pattern={{major}},value=${{ needs.release.outputs.version }} |
| 90 | + type=raw,value=latest |
| 91 | +
|
| 92 | + - name: Build and push Docker image |
| 93 | + uses: docker/build-push-action@v5 |
| 94 | + with: |
| 95 | + context: . |
| 96 | + push: true |
| 97 | + tags: ${{ steps.meta.outputs.tags }} |
| 98 | + labels: ${{ steps.meta.outputs.labels }} |
| 99 | + platforms: linux/amd64,linux/arm64 |
| 100 | + cache-from: type=gha |
| 101 | + cache-to: type=gha,mode=max |
0 commit comments