-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow that creates snapshots on push Unify publish workflows and create release automatically
- Loading branch information
1 parent
caf9a9d
commit 0216993
Showing
6 changed files
with
186 additions
and
75 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Publish snapshots | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: 11 | ||
distribution: 'adopt' | ||
server-id: github | ||
settings-path: ${{ github.workspace }} | ||
- name: Cache local Maven repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- run: mvn -B install --no-transfer-progress --file pom.xml | ||
|
||
publish-maven-snapshot: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: 11 | ||
distribution: 'adopt' | ||
server-id: github | ||
settings-path: ${{ github.workspace }} | ||
|
||
- name: Get version | ||
run: echo project_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV | ||
- name: Append "-SNAPSHOT" to projects version | ||
run: mvn versions:set "-DnewVersion=${{ env.project_version }}-SNAPSHOT" | ||
|
||
- name: Publish to GitHub Packages Apache Maven | ||
run: mvn -B --no-transfer-progress deploy -s $GITHUB_WORKSPACE/settings.xml | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
publish-npm-snapshot: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: 11 | ||
distribution: 'adopt' | ||
server-id: github | ||
settings-path: ${{ github.workspace }} | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
registry-url: https://npm.pkg.github.com | ||
|
||
- name: Get version | ||
run: echo project_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV | ||
- name: Get short commit hash | ||
run: echo commit=$(git rev-parse --short HEAD) >> $GITHUB_ENV | ||
- name: Append commit hash to projects version | ||
run: mvn versions:set "-DnewVersion=${{ env.project_version }}-${{ env.commit }}" | ||
|
||
- name: Build with Maven | ||
run: mvn -B --no-transfer-progress package --file pom.xml | ||
|
||
- name: Install dependencies | ||
working-directory: ./target/generated-sources/openapi/axios | ||
run: npm install | ||
- name: Publish npm package | ||
working-directory: ./target/generated-sources/openapi/axios | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# This workflow will build a package using Maven and publish it to GitHub Packages. It will also create a new release. | ||
|
||
name: Publish packages and create release | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: 11 | ||
distribution: 'adopt' | ||
server-id: github | ||
settings-path: ${{ github.workspace }} | ||
- name: Cache local Maven repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- run: mvn -B install --no-transfer-progress --file pom.xml | ||
|
||
publish: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: 11 | ||
distribution: 'adopt' | ||
server-id: github | ||
settings-path: ${{ github.workspace }} | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
registry-url: https://npm.pkg.github.com | ||
- name: Get version | ||
run: echo project_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_ENV | ||
|
||
- name: Publish to GitHub Packages Apache Maven | ||
run: mvn -B --no-transfer-progress deploy -s $GITHUB_WORKSPACE/settings.xml | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
- name: Install dependencies | ||
working-directory: ./target/generated-sources/openapi/axios | ||
run: npm install | ||
- name: Publish npm package | ||
working-directory: ./target/generated-sources/openapi/axios | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Create release | ||
uses: "softprops/action-gh-release@v1" | ||
with: | ||
tag_name: v${{ env.project_version }} | ||
prerelease: false | ||
name: v${{ env.project_version }} | ||
generate_release_notes: true | ||
fail_on_unmatched_files: true | ||
body: | | ||
Maven: | ||
``` | ||
<dependencies> | ||
<dependency> | ||
<groupId>care.smith.top</groupId> | ||
<artifactId>top-api</artifactId> | ||
<version>${{ env.project_version }}</version> | ||
</dependency> | ||
</dependencies> | ||
``` | ||
files: | | ||
LICENSE | ||
target/*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters