|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + - '*.*.*' |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v6 |
| 19 | + |
| 20 | + - name: Set up JDK 17 |
| 21 | + uses: actions/setup-java@v5 |
| 22 | + with: |
| 23 | + java-version: '17' |
| 24 | + distribution: 'temurin' |
| 25 | + cache: 'gradle' |
| 26 | + |
| 27 | + - name: Grant execute permission for gradlew |
| 28 | + run: chmod +x gradlew |
| 29 | + |
| 30 | + - name: Resolve release version |
| 31 | + shell: bash |
| 32 | + run: | |
| 33 | + set -euo pipefail |
| 34 | + VERSION="${GITHUB_REF_NAME#v}" |
| 35 | + echo "VERSION=${VERSION}" >> "$GITHUB_ENV" |
| 36 | +
|
| 37 | + - name: Build release artifacts |
| 38 | + run: ./gradlew clean :library:assembleRelease :library:publishReleasePublicationToMavenLocal -PLIBRARY_VERSION="$VERSION" -x test |
| 39 | + |
| 40 | + - name: Collect release artifacts |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + set -euo pipefail |
| 44 | + ARTIFACT_ID="counttimeprogressview" |
| 45 | + MAVEN_DIR="$HOME/.m2/repository/com/sfyc/ctpv/${ARTIFACT_ID}/${VERSION}" |
| 46 | + mkdir -p release-artifacts |
| 47 | + cp "library/build/outputs/aar/library-release.aar" "release-artifacts/${ARTIFACT_ID}-${VERSION}.aar" |
| 48 | + cp "${MAVEN_DIR}/${ARTIFACT_ID}-${VERSION}-sources.jar" "release-artifacts/" |
| 49 | + cp "${MAVEN_DIR}/${ARTIFACT_ID}-${VERSION}.pom" "release-artifacts/" |
| 50 | + cp "${MAVEN_DIR}/${ARTIFACT_ID}-${VERSION}.module" "release-artifacts/" |
| 51 | + (cd release-artifacts && zip "${ARTIFACT_ID}-${VERSION}.zip" *) |
| 52 | +
|
| 53 | + - name: Create or update GitHub Release |
| 54 | + env: |
| 55 | + GH_TOKEN: ${{ github.token }} |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + set -euo pipefail |
| 59 | + if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then |
| 60 | + gh release upload "$GITHUB_REF_NAME" release-artifacts/* --repo "$GITHUB_REPOSITORY" --clobber |
| 61 | + else |
| 62 | + gh release create "$GITHUB_REF_NAME" release-artifacts/* \ |
| 63 | + --repo "$GITHUB_REPOSITORY" \ |
| 64 | + --title "CountTimeProgressView ${VERSION}" \ |
| 65 | + --generate-notes |
| 66 | + fi |
0 commit comments