diff --git a/.github/workflows/ci-pipeline.yaml b/.github/workflows/ci-pipeline.yaml new file mode 100644 index 00000000..ede782ba --- /dev/null +++ b/.github/workflows/ci-pipeline.yaml @@ -0,0 +1,87 @@ +name: CI Pipeline + +on: + push: + branches: + - '*' + tags: + - '*' + +jobs: + build_binaries: + name: Build Binaries + runs-on: ubuntu-20.04 + + steps: + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.22.8 + + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Build + run: | + export PATH="$GOBIN:$PATH" + . build.sh + env: + ARTIFACTS: ${{ runner.temp }}/artifacts + shell: bash + + - name: Upload Build Artifact + uses: actions/upload-artifact@v3 + with: + name: binaries + path: ${{ runner.temp }}/artifacts/binaries + + linux: + name: Linux + runs-on: ubuntu-20.04 + needs: build_binaries + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Download Build Artifacts + uses: actions/download-artifact@v3 + with: + name: binaries + path: artifacts/binaries + + - name: Run Docker Tests + run: . run-docker-tests-linux.sh + shell: bash + + - name: Build Docker Images + run: ./build-images-linux.sh + env: + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + shell: bash + + windows: + name: Windows + runs-on: windows-2022 + needs: build_binaries + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Download Build Artifacts + uses: actions/download-artifact@v3 + with: + name: binaries + path: artifacts/binaries + + # Uncomment this step if needed once windows docker tests are implemented + # - name: Run Docker Tests (Windows) + # run: .\run-docker-tests-windows.sh + # shell: bash + + - name: Build Docker Images + run: .\build-images-windows.sh + env: + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + shell: bash diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index fd726456..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,70 +0,0 @@ -trigger: - branches: - include: - - '*' - - refs/tags/* - -jobs: -- job: Build_Binaries - pool: - vmImage: 'ubuntu-20.04' - - steps: - - task: GoTool@0 - inputs: - version: '1.22.8' - GOPATH: '$(Agent.BuildDirectory)/go' - GOBIN: '$(GOPATH)/bin' - - - bash: | - export PATH="$GOBIN:$PATH" - . build.sh - env: - ARTIFACTS: '$(Build.ArtifactStagingDirectory)' - displayName: Build - - - task: PublishBuildArtifacts@1 - inputs: - artifactName: binaries - pathtoPublish: '$(Build.ArtifactStagingDirectory)/binaries' - displayName: 'Publish Artifact' - -- job: Linux - dependsOn: Build_Binaries - pool: - vmImage: 'ubuntu-20.04' - steps: - - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifacts' - inputs: - downloadPath: artifacts - artifactName: binaries - - - bash: . run-docker-tests-linux.sh - displayName: Run docker tests - - - bash: | - ./build-images-linux.sh - displayName: 'Build docker images' - env: - DOCKER_PASSWORD: '$(DOCKER_PASSWORD)' - -- job: Windows - dependsOn: Build_Binaries - pool: - vmImage: 'windows-2022' - steps: - - task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifacts' - inputs: - downloadPath: artifacts - artifactName: binaries - - # - bash: . run-docker-tests-windows.sh - # displayName: Run docker tests - - - bash: | - ./build-images-windows.sh - displayName: 'Build docker images' - env: - DOCKER_PASSWORD: '$(DOCKER_PASSWORD)' diff --git a/build-images-linux.sh b/build-images-linux.sh index 8961a24b..2a9b52af 100755 --- a/build-images-linux.sh +++ b/build-images-linux.sh @@ -12,7 +12,7 @@ OUTPUT="type=local,dest=local" TAGS= TAGS_ALPINE= -if [[ "${BUILD_SOURCEBRANCH}" == "refs/heads/master" ]]; then +if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then echo "Building and pushing CI images" docker login -u lucaslorentz -p "$DOCKER_PASSWORD" @@ -22,8 +22,8 @@ if [[ "${BUILD_SOURCEBRANCH}" == "refs/heads/master" ]]; then TAGS_ALPINE="-t lucaslorentz/caddy-docker-proxy:ci-alpine" fi -if [[ "${BUILD_SOURCEBRANCH}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then - RELEASE_VERSION=$(echo $BUILD_SOURCEBRANCH | cut -c11-) +if [[ "${GITHUB_REF}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then + RELEASE_VERSION=$(echo $GITHUB_REF | cut -c11-) echo "Releasing version ${RELEASE_VERSION}..." diff --git a/build-images-windows.sh b/build-images-windows.sh index 90dc76d0..0f6ecfe2 100755 --- a/build-images-windows.sh +++ b/build-images-windows.sh @@ -14,7 +14,7 @@ docker build -f Dockerfile-nanoserver . \ --build-arg NANOSERVER_VERSION=ltsc2022 \ -t lucaslorentz/caddy-docker-proxy:ci-nanoserver-ltsc2022 -if [[ "${BUILD_SOURCEBRANCH}" == "refs/heads/master" ]]; then +if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then echo "Pushing CI images" docker login -u lucaslorentz -p "$DOCKER_PASSWORD" @@ -22,8 +22,8 @@ if [[ "${BUILD_SOURCEBRANCH}" == "refs/heads/master" ]]; then docker push lucaslorentz/caddy-docker-proxy:ci-nanoserver-ltsc2022 fi -if [[ "${BUILD_SOURCEBRANCH}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then - RELEASE_VERSION=$(echo $BUILD_SOURCEBRANCH | cut -c11-) +if [[ "${GITHUB_REF}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then + RELEASE_VERSION=$(echo $GITHUB_REF | cut -c11-) echo "Releasing version ${RELEASE_VERSION}..."