diff --git a/.github/workflows/build-integration.yml b/.github/workflows/build-integration.yml index fa3c22b2f..2dfcc5827 100644 --- a/.github/workflows/build-integration.yml +++ b/.github/workflows/build-integration.yml @@ -2,50 +2,50 @@ name: gocardless/stolon/build-integration on: push: branches: - - gocardless-v0.17.0+ -env: - GITHUB_TOKEN: xxxx6d08 + - gocardless-v0.17.0+ + - convert-gocardless-stolon-to-actions-20221012-105611 + jobs: unit-tests: - defaults: - run: - working-directory: "/go/src/github.com/sorintlab/stolon" runs-on: ubuntu-latest container: image: golang:1.16 steps: - - uses: actions/checkout@v2 - - name: Unit tests - run: make test + - uses: actions/checkout@v3 + - name: Unit tests + run: make test + + need-release: + runs-on: ubuntu-latest + outputs: + release: ${{ steps.get_version.outputs.release }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + # Check our VERSION file against the one in git, to see if we need to release + - name: Get version + id: get_version + run: | + CURRENT_VERSION="v$(cat VERSION)" + if [[ $(git tag -l "${CURRENT_VERSION}") == "${CURRENT_VERSION}" ]]; then + echo "Version ${CURRENT_VERSION} is already released" + echo ::set-output name=release::false + else + echo "Version ${CURRENT_VERSION} can be released" + echo ::set-output name=release::true + fi + release: - if: contains('refs/heads/gocardless-v0.17.0+', github.ref) - defaults: - run: - working-directory: "/go/src/github.com/sorintlab/stolon" + needs: need-release + if: ${{ needs.need-release.outputs.release == 'true' }} runs-on: ubuntu-latest - container: - image: golang:1.16 - needs: - - unit-tests steps: - - uses: actions/checkout@v2 - # Ensure parameter if_key_exists is set correctly - - name: Install SSH key - uses: shimataro/ssh-key-action@v2 - with: - key: "${{ secrets.CIRCLE_CI_SSH_KEY }}" - name: circle_ci_id_rsa - known_hosts: "${{ secrets.CIRCLE_CI_KNOWN_HOSTS }}" - if_key_exists: fail - - name: Release - run: |- - CURRENT_VERSION="v$(cat VERSION)" - if [[ $(git tag -l "${CURRENT_VERSION}") == "${CURRENT_VERSION}" ]]; then - echo "Version ${CURRENT_VERSION} is already released" - exit 0 - fi - curl -L -o /tmp/goreleaser_Linux_x86_64.tar.gz https://github.com/goreleaser/goreleaser/releases/download/v1.7.0/goreleaser_Linux_x86_64.tar.gz - tar zxf /tmp/goreleaser_Linux_x86_64.tar.gz -C /tmp - git tag "${CURRENT_VERSION}" - git push --tags - /tmp/goreleaser --rm-dist + - uses: actions/checkout@v3.1 + - name: Release + run: | + curl -L -o /tmp/goreleaser_Linux_x86_64.tar.gz https://github.com/goreleaser/goreleaser/releases/download/v1.7.0/goreleaser_Linux_x86_64.tar.gz + tar zxf /tmp/goreleaser_Linux_x86_64.tar.gz -C /tmp + git tag "v$(cat VERSION)" + git push --tags + /tmp/goreleaser --rm-dist