diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..27bcee3f --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,4 @@ +template: | + ## What’s Changed + + $CHANGES diff --git a/.github/workflows/feature-ci.yml b/.github/workflows/branch-ci.yml similarity index 89% rename from .github/workflows/feature-ci.yml rename to .github/workflows/branch-ci.yml index c0611d29..b6399688 100644 --- a/.github/workflows/feature-ci.yml +++ b/.github/workflows/branch-ci.yml @@ -1,18 +1,17 @@ -name: Feature Branch CI +name: Branch CI on: push: paths-ignore: - '.github/workflows/**' - - 'README.md' + - '*.md' + - '*.txt' branches-ignore: - - 'master' - - 'develop' - 'release*' jobs: build: - name: Feature Branch CI + name: Branch CI runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/master-ci.yml b/.github/workflows/master-ci.yml deleted file mode 100644 index b79bcd53..00000000 --- a/.github/workflows/master-ci.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Master branch CI - -on: - push: - branches: - - 'master' - -jobs: - build: - name: Master Branch CI - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - server-id: github - server-username: GITHUB_ACTOR - server-password: GITHUB_TOKEN - - name: Maven Build - run: mvn clean install -DskipTests=true -Ddockerfile.skip=true -B -V - env: - GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} - - name: Maven Verify - run: mvn verify -B - - name: Configure git - run: | - echo "Git checkout branch ${GITHUB_REF##*/}, commit ${GITHUB_SHA} was pushed by ${GITHUB_ACTOR}" - git checkout ${GITHUB_REF##*/} - echo "Git reset hard to ${GITHUB_SHA}" - git reset --hard ${GITHUB_SHA} - git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" - git config --global user.name "${GITHUB_ACTOR}" - - name: Prepare release - id: prepare_release - run: | - mvn --batch-mode build-helper:parse-version release:prepare -P release \ - -DreleaseVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion} \ - -DdevelopmentVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT \ - -DautoVersionSubmodules=true -Darguments="-DskipTests=true" - echo ::set-output name=release_tag::$(git describe --tags --abbrev=0) - - name: Perform release - run: mvn --batch-mode release:perform -P release -Darguments="-DskipTests=true -Ddocker.image.extra-tag=master" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }} - - name: Rollback release - if: failure() - run: | - mvn release:rollback || echo "nothing to rollback" - if [ ! -z "${{ steps.prepare_release.outputs.release_tag }}" ] - then - git tag -d ${{ steps.prepare_release.outputs.release_tag }} - git push origin :refs/tags/${{ steps.prepare_release.outputs.release_tag }} - fi diff --git a/.github/workflows/pre-release-ci.yml b/.github/workflows/pre-release-ci.yml new file mode 100644 index 00000000..664e97c9 --- /dev/null +++ b/.github/workflows/pre-release-ci.yml @@ -0,0 +1,37 @@ +name: Pre-release CI + +on: + release: + types: [prereleased] + +jobs: + build: + name: Pre-release CI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v1 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + server-id: github + server-username: GITHUB_ACTOR + server-password: GITHUB_TOKEN + - name: Deploy pre-release version + run: | + pre_release_version=${{ github.event.release.tag_name }} + echo Pre-release version $pre_release_version + mvn versions:set -DnewVersion=$pre_release_version -DgenerateBackupPoms=false + mvn versions:commit + mvn clean deploy -B -V + env: + GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} + - name: Rollback pre-release (remove tag) + if: failure() + run: git push origin :refs/tags/${{ github.event.release.tag_name }} diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml index 5624043c..d674150d 100644 --- a/.github/workflows/release-ci.yml +++ b/.github/workflows/release-ci.yml @@ -2,7 +2,7 @@ name: Release CI on: release: - types: [published] + types: [released] jobs: build: @@ -10,6 +10,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - run: git checkout ${{ github.event.release.target_commitish }} - uses: actions/cache@v1 with: path: ~/.m2/repository @@ -23,16 +26,35 @@ jobs: server-id: github server-username: GITHUB_ACTOR server-password: GITHUB_TOKEN - - name: Deploy release version - run: | - # `tag` is the concatenation of `v` and a version by the tag convention. - release_version=$(echo ${{ github.event.release.tag_name }} | sed "s/v//") - echo Release version $release_version - mvn versions:set -DnewVersion=$release_version -DgenerateBackupPoms=false - mvn versions:commit - mvn clean deploy -B -V + - name: Maven Build + run: mvn clean install -DskipTests=true -Ddockerfile.skip=true -B -V env: GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} - - name: Rollback release (remove tag) + - name: Maven Verify + run: mvn verify -B + - name: Configure git + run: | + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git config --global user.name "${GITHUB_ACTOR}" + - name: Prepare release + id: prepare_release + run: | + mvn -B build-helper:parse-version release:prepare \ + -DreleaseVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion} \ + -Darguments="-DskipTests=true -Ddockerfile.skip=true" + echo ::set-output name=release_tag::$(git describe --tags --abbrev=0) + - name: Perform release + run: mvn -B release:perform -Darguments="-DskipTests=true -Ddockerfile.skip=true" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }} + - name: Rollback release if: failure() - run: git push origin :refs/tags/${{ github.event.release.tag_name }} + run: | + mvn release:rollback || echo "nothing to rollback" + git push origin :refs/tags/${{ github.event.release.tag_name }} + if [ ! -z "${{ steps.prepare_release.outputs.release_tag }}" ] + then + git tag -d ${{ steps.prepare_release.outputs.release_tag }} + git push origin :refs/tags/${{ steps.prepare_release.outputs.release_tag }} + fi diff --git a/config-vault/src/main/java/io/scalecube/config/vault/KubernetesVaultTokenSupplier.java b/config-vault/src/main/java/io/scalecube/config/vault/KubernetesVaultTokenSupplier.java index b5497504..97877347 100644 --- a/config-vault/src/main/java/io/scalecube/config/vault/KubernetesVaultTokenSupplier.java +++ b/config-vault/src/main/java/io/scalecube/config/vault/KubernetesVaultTokenSupplier.java @@ -9,6 +9,7 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; +import java.util.stream.Stream; public class KubernetesVaultTokenSupplier implements VaultTokenSupplier { @@ -44,8 +45,8 @@ public String getToken(VaultConfig config) { Objects.requireNonNull(vaultRole, "vault role"); Objects.requireNonNull(vaultJwtProvider, "jwt provider"); Objects.requireNonNull(serviceAccountTokenPath, "k8s service account token path"); - try { - String jwt = Files.lines(Paths.get(serviceAccountTokenPath)).collect(Collectors.joining()); + try (Stream stream = Files.lines(Paths.get(serviceAccountTokenPath))) { + String jwt = stream.collect(Collectors.joining()); return Objects.requireNonNull( new Vault(config) .auth() diff --git a/pom.xml b/pom.xml index 42c3fd7d..3409dc9d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.scalecube scalecube-parent-pom - 0.2.1 + 0.2.17 scalecube-config-parent