|
| 1 | +name: Publish node |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "node/v*" |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.sha }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +env: |
| 13 | + WORKING_DIR: src |
| 14 | + |
| 15 | +jobs: |
| 16 | + container: |
| 17 | + runs-on: ton-large |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + packages: write |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v5 |
| 23 | + |
| 24 | + - name: Get commit timestamp |
| 25 | + id: commit |
| 26 | + run: echo "date=$(git log -1 --format=%cI)" >> "$GITHUB_OUTPUT" |
| 27 | + |
| 28 | + - uses: docker/setup-buildx-action@v3 |
| 29 | + |
| 30 | + - name: Log in to GHCR |
| 31 | + uses: docker/login-action@v3 |
| 32 | + with: |
| 33 | + registry: ghcr.io |
| 34 | + username: ${{ github.actor }} |
| 35 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Docker meta |
| 38 | + id: meta |
| 39 | + uses: docker/metadata-action@v5 |
| 40 | + with: |
| 41 | + images: ghcr.io/rsquad/ton-rust-node/node |
| 42 | + tags: | |
| 43 | + type=match,pattern=node/(v.*),group=1 |
| 44 | + type=raw,value=latest,enable=${{ !contains(github.ref_name, 'rc') && !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') }} |
| 45 | + type=sha |
| 46 | +
|
| 47 | + - name: Build and push |
| 48 | + uses: docker/build-push-action@v6 |
| 49 | + with: |
| 50 | + context: ./src |
| 51 | + file: ./src/Dockerfile |
| 52 | + push: true |
| 53 | + tags: ${{ steps.meta.outputs.tags }} |
| 54 | + labels: ${{ steps.meta.outputs.labels }} |
| 55 | + build-args: | |
| 56 | + GIT_BRANCH=${{ github.ref_name }} |
| 57 | + GIT_COMMIT=${{ github.sha }} |
| 58 | + GIT_COMMIT_DATE=${{ steps.commit.outputs.date }} |
| 59 | + cache-from: type=gha |
| 60 | + cache-to: type=gha,mode=max |
| 61 | + |
| 62 | + release: |
| 63 | + needs: [container] |
| 64 | + runs-on: ubuntu-latest |
| 65 | + permissions: |
| 66 | + contents: write |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v5 |
| 69 | + |
| 70 | + - name: Extract version from tag |
| 71 | + id: version |
| 72 | + run: | |
| 73 | + VERSION="${GITHUB_REF_NAME#node/}" |
| 74 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 75 | +
|
| 76 | + if echo "$VERSION" | grep -qE '(rc|alpha|beta)'; then |
| 77 | + echo "prerelease=true" >> "$GITHUB_OUTPUT" |
| 78 | + else |
| 79 | + echo "prerelease=false" >> "$GITHUB_OUTPUT" |
| 80 | + fi |
| 81 | +
|
| 82 | + - name: Create GitHub Release |
| 83 | + uses: softprops/action-gh-release@v2 |
| 84 | + with: |
| 85 | + name: "node/${{ steps.version.outputs.version }}" |
| 86 | + body: | |
| 87 | + node ${{ steps.version.outputs.version }} |
| 88 | +
|
| 89 | + Image: `ghcr.io/rsquad/ton-rust-node/node:${{ steps.version.outputs.version }}` |
| 90 | + prerelease: ${{ steps.version.outputs.prerelease }} |
| 91 | + make_latest: ${{ steps.version.outputs.prerelease != 'true' }} |
| 92 | + draft: ${{ steps.version.outputs.prerelease }} |
| 93 | + |
| 94 | + - name: Publish pre-release |
| 95 | + if: steps.version.outputs.prerelease == 'true' |
| 96 | + env: |
| 97 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + run: gh release edit "$GITHUB_REF_NAME" --draft=false |
0 commit comments