-
Notifications
You must be signed in to change notification settings - Fork 444
70 lines (61 loc) · 1.91 KB
/
ci-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: GitHub Release
on:
push:
branches:
- main
paths:
- "Version.txt"
- ".github/workflows/ci-release.yml"
# Cancel any preceding run on the pull request.
concurrency:
group: release-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
build:
if: ${{ github.repository == 'p4lang/p4c' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
run: |
VERSION="$(cat Version.txt)"
TAG="v$(cat Version.txt)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Check if tag exists
id: check_tag
run: |
TAG="${{ env.TAG }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping release creation."
echo "tag_exists=true" >> $GITHUB_OUTPUT
else
echo "Tag $TAG does not exist."
echo "tag_exists=false" >> $GITHUB_OUTPUT
fi
- name: Release
if: steps.check_tag.outputs.tag_exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image to registry
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: p4lang/p4c:${{ env.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max