|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - main
|
| 7 | + tags: |
| 8 | + - v* # Match version tags like v1.0.0 |
7 | 9 | workflow_dispatch:
|
8 | 10 |
|
9 | 11 | env:
|
|
13 | 15 | jobs:
|
14 | 16 | build:
|
15 | 17 | runs-on: ubuntu-latest
|
| 18 | + |
16 | 19 | steps:
|
| 20 | + # Step 1: Checkout the repository |
17 | 21 | - uses: actions/checkout@v4
|
18 | 22 |
|
19 |
| - # Install Rust and cross-compile the binary in release mode |
| 23 | + # Step 2: Set up Rust |
20 | 24 | - name: Set up Rust
|
21 | 25 | uses: actions-rs/toolchain@v1
|
22 | 26 | with:
|
23 | 27 | profile: minimal
|
24 | 28 | toolchain: stable
|
25 | 29 |
|
| 30 | + # Step 3: Build the binary in release mode |
26 | 31 | - name: Build in release mode
|
27 | 32 | run: cargo build --release --verbose
|
28 | 33 |
|
| 34 | + # Step 4: Install scru128-cli from GitHub |
29 | 35 | - name: Install scru128-cli from GitHub
|
30 | 36 | run: |
|
31 | 37 | cargo install --git https://github.com/cablehead/scru128-cli --branch main
|
32 | 38 | mv ~/.cargo/bin/scru128 target/release/scru128
|
33 | 39 |
|
34 |
| - # Create a Docker image, using the Dockerfile from the .github/workflows directory |
| 40 | + # Step 5: Determine Docker image tag based on ref type |
| 41 | + - name: Determine image tag |
| 42 | + id: image_tag |
| 43 | + run: | |
| 44 | + if [[ "${{ github.ref_type }}" == "tag" ]]; then |
| 45 | + echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV |
| 46 | + else |
| 47 | + echo "IMAGE_TAG=latest" >> $GITHUB_ENV |
| 48 | + fi |
| 49 | +
|
| 50 | + # Step 6: Build Docker image |
35 | 51 | - name: Build Docker image
|
36 | 52 | run: |
|
37 |
| - docker build -t $IMAGE_NAME:latest -f .github/workflows/Dockerfile.release-docker . |
| 53 | + docker build -t $IMAGE_NAME:$IMAGE_TAG -f .github/workflows/Dockerfile.release-docker . |
38 | 54 |
|
39 |
| - # Log in to the GitHub Container Registry (GHCR) |
| 55 | + # Step 7: Log in to GitHub Container Registry |
40 | 56 | - name: Log in to GitHub Container Registry
|
41 | 57 | run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
42 | 58 |
|
43 |
| - # Push the Docker image to GHCR |
| 59 | + # Step 8: Push Docker image to GHCR |
44 | 60 | - name: Push Docker image
|
45 |
| - run: docker push $IMAGE_NAME:latest |
| 61 | + run: docker push $IMAGE_NAME:$IMAGE_TAG |
0 commit comments