diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 02e6049..e42f6dc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,35 +1,621 @@ -# Go -# Build your Go project. -# Add steps that test, save build artifacts, deploy, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/go - parameters: - name: version - displayName: Release Version + displayName: Release Version (e.g. v0.1.0) type: string + - name: artifactBuildId + displayName: "Artifact source build id (defaults uses this build)" + type: number + default: 0 + +variables: + - name: pipelineId + value: 22 + +stages: + - stage: build + pool: + name: pool-ubuntu-2004 + displayName: "Build aztfy" + jobs: + - job: build + displayName: "Build Binaries" + strategy: + matrix: + windows-386: + OS: windows + ARCH: 386 + windows-amd64: + OS: windows + ARCH: amd64 + linux-386: + OS: linux + ARCH: 386 + linux-amd64: + OS: linux + ARCH: amd64 + linux-arm: + OS: linux + ARCH: arm + linux-arm64: + OS: linux + ARCH: arm64 + darwin-amd64: + OS: darwin + ARCH: amd64 + darwin-arm64: + OS: darwin + ARCH: arm64 + steps: + - task: GoTool@0 + displayName: "Install Go" + inputs: + version: 1.19 + - script: | + set -e + REVISION=`git rev-parse --short HEAD` + mkdir build + name=aztfy + if [[ $OS = windows ]]; then + name=aztfy.exe + fi + GOOS="${OS}" GOARCH="${ARCH}" CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X 'main.version=${VERSION}' -X 'main.revision=${REVISION}'" -o build/$name + displayName: "Go Build" + env: + OS: $(OS) + ARCH: $(ARCH) + VERSION: ${{ parameters.version }} + - task: EsrpCodeSigning@1 + displayName: "Sign Binary (Windows Only)" + condition: eq(variables.OS, 'windows') + inputs: + ConnectedServiceName: "ESRP Signing Service" + FolderPath: "$(system.defaultWorkingDirectory)/build" + Pattern: "*.exe" + signConfigType: "inlineSignParams" + inlineOperation: | + [ + { + "KeyCode" : "CP-230012", + "OperationCode" : "SigntoolSign", + "Parameters" : { + "OpusName" : "Microsoft", + "OpusInfo" : "http://www.microsoft.com", + "PageHash" : "/NPH", + "TimeStamp" : "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256", + "FileDigest": "/fd \"SHA256\"" + }, + "ToolName" : "sign", + "ToolVersion" : "1.0" + }, + { + "KeyCode" : "CP-230012", + "OperationCode" : "SigntoolVerify", + "Parameters" : {}, + "ToolName" : "sign", + "ToolVersion" : "1.0" + } + ] + SessionTimeout: "60" + MaxConcurrency: "50" + MaxRetryAttempts: "5" + - task: PublishPipelineArtifact@1 + displayName: "Publish Binary" + inputs: + targetPath: "$(system.defaultWorkingDirectory)/build" + artifactName: "$(OS)-$(ARCH)" + + - job: build_windows_setup + displayName: "Build Windows Setup" + pool: + name: pool-windows-2019 + dependsOn: build + strategy: + matrix: + 386: + ARCH: 386 + amd64: + ARCH: amd64 + steps: + - task: DownloadPipelineArtifact@2 + displayName: "Download aztfy binary" + inputs: + artifact: windows-$(ARCH) + path: $(system.defaultWorkingDirectory)/dist/bin + - task: UniversalPackages@0 + displayName: "Download wix toolset" + inputs: + command: download + vstsFeed: "release/aztfy" + vstsFeedPackage: "wixsetup" + vstsPackageVersion: "3.11.2" + downloadDirectory: $(system.defaultWorkingDirectory)/dist/tool + - bash: | + set -e + + # Setup wix + ./dist/tool/wix311.exe -install -quiet -norestart + export PATH=$PATH:"/c/Program Files (x86)/WiX Toolset v3.11/bin" + + # Build + cd $workdir/scripts/package/windows/build + declare -A map=( [386]=x86 [amd64]=x64 ) + export VERSION=${VERSION:1} + cp $workdir/dist/bin/aztfy.exe . + candle.exe -arch ${map[$ARCH]} -o setup.wxobj ./setup.wxs + mkdir $workdir/dist/output + light.exe -out $workdir/dist/output/aztfy.msi ./setup.wxobj + env: + workdir: $(system.defaultWorkingDirectory) + VERSION: ${{ parameters.version }} + ARCH: $(ARCH) + displayName: "Build" + - task: EsrpCodeSigning@1 + displayName: "Sign MSI" + inputs: + ConnectedServiceName: "ESRP Signing Service" + FolderPath: "$(system.defaultWorkingDirectory)/dist/output" + Pattern: "*.msi" + signConfigType: "inlineSignParams" + inlineOperation: | + [ + { + "KeyCode" : "CP-230012", + "OperationCode" : "SigntoolSign", + "Parameters" : { + "OpusName" : "Microsoft", + "OpusInfo" : "http://www.microsoft.com", + "PageHash" : "/NPH", + "TimeStamp" : "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256", + "FileDigest": "/fd \"SHA256\"" + }, + "ToolName" : "sign", + "ToolVersion" : "1.0" + }, + { + "KeyCode" : "CP-230012", + "OperationCode" : "SigntoolVerify", + "Parameters" : {}, + "ToolName" : "sign", + "ToolVersion" : "1.0" + } + ] + SessionTimeout: "60" + MaxConcurrency: "50" + MaxRetryAttempts: "5" + - task: PublishPipelineArtifact@1 + displayName: "Publish MSI" + inputs: + targetPath: "$(system.defaultWorkingDirectory)/dist/output" + artifactName: windows-$(ARCH)-msi + + - job: build_linux_packages + displayName: "Build Linux RPM/Debian Packages" + dependsOn: build + strategy: + matrix: + linux-386: + OS: linux + ARCH: 386 + linux-amd64: + OS: linux + ARCH: amd64 + linux-arm: + OS: linux + ARCH: arm + linux-arm64: + OS: linux + ARCH: arm64 + steps: + - task: DownloadPipelineArtifact@2 + inputs: + artifact: $(OS)-$(ARCH) + path: $(system.defaultWorkingDirectory)/dist/source + - script: | + mkdir $workdir/dist/output + displayName: "Prepare the output directory" + env: + workdir: $(system.defaultWorkingDirectory) + - script: | + set -e + + chmod +x $WORKDIR/dist/source/aztfy + + declare -A deb_arch_map=( [386]=i386 [amd64]=amd64 [arm]=armhf [arm64]=arm64 ) + declare -A rpm_arch_map=( [386]=i686 [amd64]=x86_64 [arm]=armv7hl [arm64]=aarch64 ) + version=${VERSION:1} + + # Build the image + cd $WORKDIR/scripts/package/linux/build + docker build -t aztfybuild . + + # Build deb package + docker run -t --rm \ + -v $WORKDIR/dist/source:/build/source \ + -v $WORKDIR/dist/output:/build/output \ + aztfybuild \ + fpm \ + --name aztfy \ + --license MPL-2.0 \ + --version $version \ + --description "A tool to bring existing Azure resources under Terraform's management" \ + --url "https://github.com/Azure/aztfy" \ + --maintainer "magodo " \ + --input-type dir \ + --output-type deb \ + --architecture ${deb_arch_map[$ARCH]} \ + --package /build/output/aztfy-$version-1-${deb_arch_map[$ARCH]}.deb \ + /build/source/aztfy=/usr/bin/aztfy + + # Build rpm package + echo $version + docker run -t --rm \ + -v $WORKDIR/dist/source:/build/source \ + -v $WORKDIR/dist/output:/build/output \ + aztfybuild \ + fpm \ + --name aztfy \ + --license MPL-2.0 \ + --version ${version} \ + --description "A tool to bring existing Azure resources under Terraform's management" \ + --url "https://github.com/Azure/aztfy" \ + --maintainer "magodo " \ + --input-type dir \ + --output-type rpm \ + --architecture ${rpm_arch_map[$ARCH]} \ + --package /build/output/aztfy-$version-1-${rpm_arch_map[$ARCH]}.rpm \ + /build/source/aztfy=/usr/bin/aztfy + displayName: "Build Packages" + env: + VERSION: ${{ parameters.version }} + WORKDIR: $(system.defaultWorkingDirectory) + - task: EsrpCodeSigning@1 + displayName: "Sign Package" + inputs: + ConnectedServiceName: "ESRP Signing Service" + FolderPath: "$(system.defaultWorkingDirectory)/dist/output" + Pattern: "*.rpm,*.deb" + signConfigType: "inlineSignParams" + inlineOperation: | + [ + { + "KeyCode": "CP-450779-Pgp", + "OperationCode": "LinuxSign", + "Parameters": {}, + "ToolName": "sign", + "ToolVersion": "1.0" + } + ] + SessionTimeout: "60" + MaxConcurrency: "50" + MaxRetryAttempts: "5" + - task: PublishPipelineArtifact@1 + displayName: "Publish Packages" + inputs: + targetPath: "$(system.defaultWorkingDirectory)/dist/output" + artifactName: $(OS)-$(ARCH)-pkg + + - stage: github_release + displayName: "Github Draft Release" + pool: + name: pool-ubuntu-2004 + jobs: + - job: release + displayName: "Github Release" + steps: + - ${{ if eq(parameters.artifactBuildId, 0) }}: + - task: DownloadPipelineArtifact@2 + inputs: + path: $(system.defaultWorkingDirectory)/dist + - ${{ else }}: + - task: DownloadPipelineArtifact@2 + inputs: + path: $(system.defaultWorkingDirectory)/dist + source: "specific" + project: "release" + pipeline: $(pipelineId) + runVersion: "specific" + runId: ${{ parameters.artifactBuildId }} + - script: | + set -e + NAME="aztfy" + OS_ARCH=( + "windows:amd64" + "windows:386" + "linux:amd64" + "linux:386" + "linux:arm" + "linux:arm64" + "darwin:amd64" + "darwin:arm64" + ) + mkdir release + for os_arch in "${OS_ARCH[@]}" ; do + OS=${os_arch%%:*} + ARCH=${os_arch#*:} + name=aztfy + if [[ $OS = windows ]]; then + name=aztfy.exe + fi + chmod +x dist/${OS}-${ARCH}/${name} + zip -j release/${NAME}_${VERSION}_${OS}_${ARCH}.zip dist/${OS}-${ARCH}/${name} + done + + # Copy MSI + cp dist/windows-386-msi/aztfy.msi release/${NAME}_${VERSION}_x86.msi + cp dist/windows-amd64-msi/aztfy.msi release/${NAME}_${VERSION}_x64.msi + + cd release + shasum -a 256 *.zip *.msi > ${NAME}_SHA256SUMS + cp ${NAME}_SHA256SUMS ${NAME}_SHA256SUMS.sig + displayName: "Prepare Binary Archives & Digests" + env: + VERSION: ${{ parameters.version }} + - task: EsrpCodeSigning@1 + displayName: "Sign Binary Archive Digests" + inputs: + ConnectedServiceName: "ESRP Signing Service" + FolderPath: "$(system.defaultWorkingDirectory)/release" + Pattern: "*_SHA256SUMS.sig" + signConfigType: "inlineSignParams" + inlineOperation: | + [ + { + "KeyCode": "CP-450779-Pgp", + "OperationCode": "LinuxSign", + "Parameters": {}, + "ToolName": "sign", + "ToolVersion": "1.0" + } + ] + SessionTimeout: "60" + MaxConcurrency: "50" + MaxRetryAttempts: "5" + - task: GitHubRelease@1 + displayName: "Draft Github Release" + inputs: + gitHubConnection: "Github" + repositoryName: "$(Build.Repository.Name)" + action: "create" + target: "$(Build.SourceVersion)" + tagSource: "gitTag" + tagPattern: '^v\d+\.\d+\.\d+' + assets: "$(system.defaultWorkingDirectory)/release/*" + isDraft: true + addChangeLog: false + + - stage: publish_linux_packages + displayName: "Publish Linux Packages" + pool: + name: pool-ubuntu-2004 + jobs: + - job: publish + displayName: "Publish Packages" + strategy: + matrix: + # deb platforms + # ubuntu-bionic-amd64: + # TYPE: deb + # ARCH: amd64 + # REPO_ID: 5d16326637164fbc1139c4e1 + # REPO_DISTRO: ubuntu + # REPO_RELEASE: bionic + # ubuntu-bionic-arm64: + # TYPE: deb + # ARCH: arm64 + # REPO_ID: 5d16326637164fbc1139c4e1 + # REPO_DISTRO: ubuntu + # REPO_RELEASE: bionic + ubuntu-focal-amd64: + TYPE: deb + ARCH: amd64 + REPO_ID: 5e852952e45fffa1beda61fe + REPO_DISTRO: ubuntu + REPO_RELEASE: focal + ubuntu-focal-arm64: + TYPE: deb + ARCH: arm64 + REPO_ID: 5e852952e45fffa1beda61fe + REPO_DISTRO: ubuntu + REPO_RELEASE: focal + ubuntu-jammy-amd64: + TYPE: deb + ARCH: amd64 + REPO_ID: 61faea6cea3a770ab120ac8a + REPO_DISTRO: ubuntu + REPO_RELEASE: jammy + ubuntu-jammy-arm64: + TYPE: deb + ARCH: arm64 + REPO_ID: 61faea6cea3a770ab120ac8a + REPO_DISTRO: ubuntu + REPO_RELEASE: jammy + # debian-buster-amd64: + # TYPE: deb + # ARCH: amd64 + # REPO_ID: 5d23b16c9a6e3b375bbba42e + # REPO_DISTRO: debian + # REPO_RELEASE: buster + # debian-buster-arm64: + # TYPE: deb + # ARCH: arm64 + # REPO_ID: 5d23b16c9a6e3b375bbba42e + # REPO_DISTRO: debian + # REPO_RELEASE: buster + # debian-bullseye-amd64: + # TYPE: deb + # ARCH: amd64 + # REPO_ID: 611ab3a32acdcd0744c8c841 + # REPO_DISTRO: debian + # REPO_RELEASE: bullseye + # debian-bullseye-arm64: + # TYPE: deb + # ARCH: arm64 + # REPO_ID: 611ab3a32acdcd0744c8c841 + # REPO_DISTRO: debian + # REPO_RELEASE: bullseye + + # rpm platforms + # centos-8-x86_64: + # TYPE: rpm + # ARCH: amd64 + # REPO_ID: 5e5ed94a523a8019fe47607e + # REPO_DISTRO: centos + # REPO_RELEASE: 8 + # centos-8-aarch64: + # TYPE: rpm + # ARCH: arm64 + # REPO_ID: 5e5ed94a523a8019fe47607e + # REPO_DISTRO: centos + # REPO_RELEASE: 8 + rhel-8-x86_64: + TYPE: rpm + ARCH: amd64 + REPO_ID: 5d4470e1eebce7156eee5407 + REPO_DISTRO: rhel + REPO_RELEASE: 8 + rhel-8-aarch64: + TYPE: rpm + ARCH: arm64 + REPO_ID: 5d4470e1eebce7156eee5407 + REPO_DISTRO: rhel + REPO_RELEASE: 8 + rhel-9-x86_64: + TYPE: rpm + ARCH: amd64 + REPO_ID: 627067cc3ac6d7548f4d66cd + REPO_DISTRO: rhel + REPO_RELEASE: 9 + rhel-9-aarch64: + TYPE: rpm + ARCH: arm64 + REPO_ID: 627067cc3ac6d7548f4d66cd + REPO_DISTRO: rhel + REPO_RELEASE: 9 + # fedora-34-x86_64: + # TYPE: rpm + # ARCH: amd64 + # REPO_ID: 606e1da573e50659b0803a7b + # REPO_DISTRO: fedora + # REPO_RELEASE: 34 + # fedora-34-aarch64: + # TYPE: rpm + # ARCH: arm64 + # REPO_ID: 606e1da573e50659b0803a7b + # REPO_DISTRO: fedora + # REPO_RELEASE: 34 + # fedora-35-x86_64: + # TYPE: rpm + # ARCH: amd64 + # REPO_ID: 6196d483ea3a770f011f63fb + # REPO_DISTRO: fedora + # REPO_RELEASE: 35 + # fedora-35-aarch64: + # TYPE: rpm + # ARCH: arm64 + # REPO_ID: 6196d483ea3a770f011f63fb + # REPO_DISTRO: fedora + # REPO_RELEASE: 35 + # fedora-36-x86_64: + # TYPE: rpm + # ARCH: amd64 + # REPO_ID: 6271bc683ac6d73aa84d6737 + # REPO_DISTRO: fedora + # REPO_RELEASE: 36 + # fedora-36-aarch64: + # TYPE: rpm + # ARCH: arm64 + # REPO_ID: 6271bc683ac6d73aa84d6737 + # REPO_DISTRO: fedora + # REPO_RELEASE: 36 + steps: + - ${{ if eq(parameters.artifactBuildId, 0) }}: + - task: DownloadPipelineArtifact@2 + inputs: + artifact: linux-$(ARCH)-pkg + path: $(system.defaultWorkingDirectory)/dist/pkg + - ${{ else }}: + - task: DownloadPipelineArtifact@2 + inputs: + artifact: linux-$(ARCH)-pkg + path: $(system.defaultWorkingDirectory)/dist/pkg + source: "specific" + project: "release" + pipeline: $(pipelineId) + runVersion: "specific" + runId: ${{ parameters.artifactBuildId }} + - task: UniversalPackages@0 + displayName: "Download repoclient" + inputs: + command: download + vstsFeed: "release/aztfy" + vstsFeedPackage: "azure-repoapi-client" + vstsPackageVersion: "2.2.1" + downloadDirectory: $(system.defaultWorkingDirectory)/dist/tool + - script: | + set -e + sudo apt install -y ./dist/tool/azure-repoapi-client_2.2.1_amd64.deb + mkdir ~/.repoclient + cat << EOF > ~/.repoclient/config.json + { + "server": "azure-apt-cat.cloudapp.net", + "port": "443", + "AADClientId": "$(LINUX_REPO_SP_CLIENT_ID)", + "AADClientSecret": "$(LINUX_REPO_SP_CLIENT_SECRET)", + "AADResource": "https://microsoft.onmicrosoft.com/945999e9-da09-4b5b-878f-b66c414602c0", + "AADTenant": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "AADAuthorityUrl": "https://login.microsoftonline.com", + "repositoryId": "IGNORE" + } + EOF + pkg=(./dist/pkg/*.${TYPE}) + [[ ${#pkg[@]} == 1 ]] || { echo "not exactly one target packages found: $(declare -p pkg)" > 2; exit 1; } + pkg=${pkg[0]} + + # Allow error's to occur prior to quit the task, as we are capturing the command output, otherwise, we will have no chance to output that in stdout/stderr. + set +e + ret=$(repoclient package add -r ${REPO_ID} $pkg) + [[ $? == 0 ]] || { echo "Error: repoclient package add failed: $ret" >&2; exit 1; } + echo -e "repoclient package add returns:\n$ret\n" + + location=$(jq -r '.Location' <<< $ret) + package_id=${location##*/} + [[ -n $package_id ]] || { echo "Error: empty package id got" >&2; exit 1; } + echo "package id: $package_id" + + ret=$(repoclient package check $package_id) + [[ $? == 0 ]] || { echo "Error: repoclient package check failed: $ret" >&2; exit 1; } + echo -e "repoclient package check returns:\n$ret\n" + displayName: "Publish via repoclient" + env: + TYPE: $(TYPE) + REPO_ID: $(REPO_ID) + - script: | + set -e + + # Skip verifying rhel distros as they don't have a docker image available + [[ $REPO_DISTRO == rhel ]] && exit 0 + + # Install and run kvm service + sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon + sudo systemctl enable --now libvirtd + + # Setup binfmt_misc to enable multi arch + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + + # Launch the base container of the correct architecture + cid=$(docker run --rm -dit --platform=linux/$ARCH ${REPO_DISTRO}:${REPO_RELEASE}) + + docker cp ${workdir}/scripts/package/linux/verify/${REPO_DISTRO}-${REPO_RELEASE}.sh ${cid}:/verify.sh + docker exec $cid /verify.sh $VERSION + displayName: "Verify" + env: + workdir: $(system.defaultWorkingDirectory) + TYPE: $(TYPE) + ARCH: $(ARCH) + REPO_ID: $(REPO_ID) + REPO_DISTRO: $(REPO_DISTRO) + REPO_RELEASE: $(REPO_RELEASE) + VERSION: ${{ parameters.version }} -jobs: - -- job: Package - pool: - vmImage: 'ubuntu-latest' - - steps: - - task: GoTool@0 - displayName: 'Install Go' - inputs: - version: 1.18 - GOPATH: '$(Pipeline.Workspace)/gopath' - GOBIN: '$(GOPATH)/bin' - - - task: Bash@3 - displayName: "Build Packages" - inputs: - filePath: '$(system.defaultWorkingDirectory)/scripts/build.sh' - env: - VERSION: ${{ parameters.version }} - - task: PublishPipelineArtifact@1 - inputs: - targetPath: '$(system.defaultWorkingDirectory)/dist/' - artifact: 'artifact' - publishLocation: 'pipeline' + # - stage: publish_windows_setup + # displayName: "Publish Windows Setup" diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100644 index dee245c..0000000 --- a/scripts/build.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -REVISION=$(git rev-parse --short HEAD) -OS_ARCH=("freebsd:amd64" - "freebsd:386" - "freebsd:arm" - "freebsd:arm64" - "windows:amd64" - "windows:386" - "linux:amd64" - "linux:386" - "linux:arm" - "linux:arm64" - "darwin:amd64" - "darwin:arm64") -mkdir dist -for os_arch in "${OS_ARCH[@]}" ; do - OS=${os_arch%%:*} - ARCH=${os_arch#*:} - echo "GOOS: ${OS}, GOARCH: ${ARCH}" - - output=aztfy_${OS}_${ARCH} - if [[ $OS = windows ]]; then - output=$output.exe - fi - - GOOS="${OS}" GOARCH="${ARCH}" CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X 'main.version=${VERSION}' -X 'main.revision=${REVISION}'" -o $output - mv $output dist -done diff --git a/scripts/package/linux/build/Dockerfile b/scripts/package/linux/build/Dockerfile new file mode 100644 index 0000000..c736f8e --- /dev/null +++ b/scripts/package/linux/build/Dockerfile @@ -0,0 +1,6 @@ +FROM ubuntu:22.04 +ARG version +RUN apt update && apt install -y ruby-dev build-essential squashfs-tools +RUN apt install -y rpm +RUN gem i fpm +CMD ["fpm", "--help"] diff --git a/scripts/package/linux/verify/centos-8.sh b/scripts/package/linux/verify/centos-8.sh new file mode 100755 index 0000000..64a0cfa --- /dev/null +++ b/scripts/package/linux/verify/centos-8.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +version=${1:?"version not specified"} + +sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* +sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* +rpm --import https://packages.microsoft.com/keys/microsoft.asc +dnf install -y https://packages.microsoft.com/config/centos/8/packages-microsoft-prod.rpm + +total=60 +count=1 +while ((count <= total)); do + echo "Try ($count/$total)" + # See: https://access.redhat.com/solutions/2779441 + dnf check-update --refresh || [[ $? == 100 ]] + dnf install -y aztfy && break + + sleep 1m + ((count++)) +done +(( count <= total )) + +grep $version <(aztfy -v) diff --git a/scripts/package/linux/verify/debian-bullseye.sh b/scripts/package/linux/verify/debian-bullseye.sh new file mode 100755 index 0000000..dc2d50d --- /dev/null +++ b/scripts/package/linux/verify/debian-bullseye.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +version=${1:?"version not specified"} + +apt-get update +apt-get install -y curl software-properties-common gpg +curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add - +apt-add-repository https://packages.microsoft.com/debian/11/prod + +total=60 +count=1 +while ((count <= total)); do + echo "Try ($count/$total)" + apt-get update + apt-get install -y aztfy && break + + sleep 1m + ((count++)) +done +(( count <= total )) + +grep $version <(aztfy -v) diff --git a/scripts/package/linux/verify/debian-buster.sh b/scripts/package/linux/verify/debian-buster.sh new file mode 100755 index 0000000..a9f0708 --- /dev/null +++ b/scripts/package/linux/verify/debian-buster.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +version=${1:?"version not specified"} + +apt-get update +apt-get install -y curl software-properties-common gpg +curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add - +apt-add-repository https://packages.microsoft.com/debian/10/prod + +total=60 +count=1 +while ((count <= total)); do + echo "Try ($count/$total)" + apt-get update + apt-get install -y aztfy && break + + sleep 1m + ((count++)) +done +(( count <= total )) + +grep $version <(aztfy -v) diff --git a/scripts/package/linux/verify/fedora-34.sh b/scripts/package/linux/verify/fedora-34.sh new file mode 100755 index 0000000..3b9d849 --- /dev/null +++ b/scripts/package/linux/verify/fedora-34.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +version=${1:?"version not specified"} + +rpm --import https://packages.microsoft.com/keys/microsoft.asc + +# To accelarate syncing the repo metadatas +rm -f /etc/yum.repos.d/* + +dnf install -y https://packages.microsoft.com/config/fedora/34/packages-microsoft-prod.rpm + +total=60 +count=1 +while ((count <= total)); do + echo "Try ($count/$total)" + # See: https://access.redhat.com/solutions/2779441 + dnf check-update --refresh || [[ $? == 100 ]] + dnf install -y aztfy && break + + sleep 1m + ((count++)) +done +(( count <= total )) + +grep $version <(aztfy -v) diff --git a/scripts/package/linux/verify/fedora-35.sh b/scripts/package/linux/verify/fedora-35.sh new file mode 100755 index 0000000..30ba916 --- /dev/null +++ b/scripts/package/linux/verify/fedora-35.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +version=${1:?"version not specified"} + +rpm --import https://packages.microsoft.com/keys/microsoft.asc + +# To accelarate syncing the repo metadatas +rm -f /etc/yum.repos.d/* + +dnf install -y https://packages.microsoft.com/config/fedora/35/packages-microsoft-prod.rpm + +total=60 +count=1 +while ((count <= total)); do + echo "Try ($count/$total)" + # See: https://access.redhat.com/solutions/2779441 + dnf check-update --refresh || [[ $? == 100 ]] + dnf install -y aztfy && break + + sleep 1m + ((count++)) +done +(( count <= total )) + +grep $version <(aztfy -v) diff --git a/scripts/package/linux/verify/fedora-36.sh b/scripts/package/linux/verify/fedora-36.sh new file mode 100755 index 0000000..33b6018 --- /dev/null +++ b/scripts/package/linux/verify/fedora-36.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +version=${1:?"version not specified"} + +rpm --import https://packages.microsoft.com/keys/microsoft.asc + +# To accelarate syncing the repo metadatas +rm -f /etc/yum.repos.d/* + +dnf install -y https://packages.microsoft.com/config/fedora/36/packages-microsoft-prod.rpm + +total=60 +count=1 +while ((count <= total)); do + echo "Try ($count/$total)" + # See: https://access.redhat.com/solutions/2779441 + dnf check-update --refresh || [[ $? == 100 ]] + dnf install -y aztfy && break + + sleep 1m + ((count++)) +done +(( count <= total )) + +grep $version <(aztfy -v) diff --git a/scripts/package/linux/verify/ubuntu-bionic.sh b/scripts/package/linux/verify/ubuntu-bionic.sh new file mode 100755 index 0000000..7f335e8 --- /dev/null +++ b/scripts/package/linux/verify/ubuntu-bionic.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +version=${1:?"version not specified"} + +apt-get update +apt-get install -y curl software-properties-common gpg +curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add - +apt-add-repository https://packages.microsoft.com/ubuntu/18.04/multiarch/prod + +total=60 +count=1 +while ((count <= total)); do + echo "Try ($count/$total)" + apt-get update + apt-get install -y aztfy && break + + sleep 1m + ((count++)) +done +(( count <= total )) + +grep $version <(aztfy -v) diff --git a/scripts/package/linux/verify/ubuntu-focal.sh b/scripts/package/linux/verify/ubuntu-focal.sh new file mode 100755 index 0000000..8f9ca00 --- /dev/null +++ b/scripts/package/linux/verify/ubuntu-focal.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +version=${1:?"version not specified"} + +apt-get update +apt-get install -y curl software-properties-common gpg +curl -sSL https://packages.microsoft.com/keys/microsoft.asc > /etc/apt/trusted.gpg.d/microsoft.asc +apt-add-repository https://packages.microsoft.com/ubuntu/20.04/prod + +total=60 +count=1 +while ((count <= total)); do + echo "Try ($count/$total)" + apt-get update + apt-get install -y aztfy && break + + sleep 1m + ((count++)) +done +(( count <= total )) + +grep $version <(aztfy -v) diff --git a/scripts/package/linux/verify/ubuntu-jammy.sh b/scripts/package/linux/verify/ubuntu-jammy.sh new file mode 100755 index 0000000..90c72b0 --- /dev/null +++ b/scripts/package/linux/verify/ubuntu-jammy.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +version=${1:?"version not specified"} + +apt-get update +apt-get install -y curl software-properties-common gpg +curl -sSL https://packages.microsoft.com/keys/microsoft.asc > /etc/apt/trusted.gpg.d/microsoft.asc +apt-add-repository https://packages.microsoft.com/ubuntu/22.04/prod + +total=60 +count=1 +while ((count <= total)); do + echo "Try ($count/$total)" + apt-get update + apt-get install -y aztfy && break + + sleep 1m + ((count++)) +done + +grep $version <(aztfy -v) diff --git a/scripts/package/windows/build/setup.wxs b/scripts/package/windows/build/setup.wxs new file mode 100644 index 0000000..9e102a1 --- /dev/null +++ b/scripts/package/windows/build/setup.wxs @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +