-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (107 loc) · 3.93 KB
/
Copy pathrelease.yml
File metadata and controls
122 lines (107 loc) · 3.93 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: CI & Release
permissions:
contents: write
packages: write
on:
pull_request:
push:
branches: [main]
tags:
- "v*"
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install capnp and Rust
run: |
sudo apt-get update
sudo apt-get install -y capnproto
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: maven
- name: Build native snownoise
run: cargo build --release --manifest-path native/snownoise/Cargo.toml
- name: Run tests
env:
SNOWNOISE_LIB_PATH: ${{ github.workspace }}/native/snownoise/target/release
run: mvn -B test
publish:
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install capnp and Rust
run: |
sudo apt-get update
sudo apt-get install -y capnproto
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: maven
server-id: central
server-username: ${{ secrets.CENTRAL_USERNAME }}
server-password: ${{ secrets.CENTRAL_PASSWORD }}
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Compute version
run: |
BASE_VERSION=$(mvn -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec)
CANDIDATE_VERSION="${BASE_VERSION}"
# If the computed tag already exists on origin, bump the patch until we find a free version.
while git ls-remote --tags origin "refs/tags/v${CANDIDATE_VERSION}" | grep -q .; do
IFS='.' read -r MAJOR MINOR PATCH <<< "${CANDIDATE_VERSION}"
PATCH=$((PATCH + 1))
CANDIDATE_VERSION="${MAJOR}.${MINOR}.${PATCH}"
done
# If we bumped, update the project version for this build (no backup pom).
if [ "${CANDIDATE_VERSION}" != "${BASE_VERSION}" ]; then
mvn -B versions:set -DnewVersion="${CANDIDATE_VERSION}" -DgenerateBackupPoms=false
fi
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
TAG_NAME="${GITHUB_REF_NAME}"
else
TAG_NAME="v${CANDIDATE_VERSION}"
fi
echo "RELEASE_VERSION=${CANDIDATE_VERSION}" >> $GITHUB_ENV
echo "RELEASE_TAG=${TAG_NAME}" >> $GITHUB_ENV
- name: Create tag (main/workflow_dispatch)
if: github.ref_type != 'tag'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "${RELEASE_TAG}"
git push origin "${RELEASE_TAG}"
- name: Build native snownoise
run: cargo build --release --manifest-path native/snownoise/Cargo.toml
- name: Build and deploy
env:
SNOWNOISE_LIB_PATH: ${{ github.workspace }}/native/snownoise/target/release
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn -B -DskipTests -DperformRelease -Pcentral deploy -e
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.RELEASE_TAG }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}