I get the below error when i try to create a release dynamically with octopusdpeloy via github actions
Action code
- name: Create a release in Octopus Deploy
uses: OctopusDeploy/create-release-action#v2
env:
OCTOPUS_API_KEY: ${{ inputs.OCTOPUS_APIKEY }}
OCTOPUS_HOST: "https://octopusdev.fidev.com/"
with:
project: ${{ github.event.repository.name }}
packages: {Deployartifact}:{${{ steps.deploy_setup.outputs.JFROG_VERSION }}}
Run OctopusDeploy/install-octopus-cli-action#v1
Latest version available: 9.1.7
✓ Octopus CLI version found: 9.1.7
⬇️ Downloading Octopus CLI 9.1.7...
📦 Extracting Octopus CLI 9.1.7...
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'E:\actions-runner\workspace\_temp\2712f7bc-357a-4509-93d3-2318c71651bd.zip' -DestinationPath 'E:\actions-runner\workspace\_temp\86a0af86-765f-4e8f-9e13-9a642c6bd7f2' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('E:\actions-runner\workspace\_temp\2712f7bc-357a-4509-93d3-2318c71651bd.zip', 'E:\actions-runner\workspace\_temp\86a0af86-765f-4e8f-9e13-9a642c6bd7f2', $true) }"
🐙 Octopus CLI 9.1.7 installed successfully
Run OctopusDeploy/create-release-action#v2
The package argument 'Deployartifact:' does not use expected format of : {Step Name}:{Version}
Exit code: -1
Error: Error: The process 'E:\actions-runner\workspace\_tool\octo\9.1.7\x64\octo.exe' failed with exit code 4294967295
You need to change your packages line to be:
packages: Deployartifact:${{ steps.deploy_setup.outputs.JFROG_VERSION }}
The packages reference does not need the extra braces, just use either PackageID:version or StepName:PackageId:Version.
Related
Since around October 16 2022 we have problems with installing MiKTeX under GitHub Actions.
The error we get is:
Run ./miktexsetup_standalone --local-package-repository=C:/miktex-repository \
./miktexsetup_standalone --local-package-repository=C:/miktex-repository \
--package-set=essential \
--shared \
install
shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0}
initexmf.exe: The executed process did not succeed.
initexmf.exe: Data: fileName="C:\Program Files\MiKTeX\miktex\bin\x64\initexmf.exe", exitCode="1"
Error: Process completed with exit code 1.
The procedure followed in GitHub Actions consists of a few steps:
Step 1:
- name: Download MikTex (Windows)
run: |
$wc = New-Object System.Net.WebClient;
$maxAttempts=5;
$attemptCount=0;
Do {
$attemptCount++;
Try {
$wc.DownloadFile("https://ctan.math.illinois.edu/systems/win32/miktex/setup/windows-x64/miktexsetup-5.1-x64.zip","miktexsetup-5.1-x64.zip")
} Catch [Exception] {
Write-Host $_.Exception | format-list -force
}
} while (((Test-Path "miktexsetup-5.1-x64.zip") -eq $false) -and ($attemptCount -le $maxAttempts))
shell: pwsh
if: matrix.config.os == 'windows-latest'
Step 2:
- name: Extract MikTex zip (Windows)
shell: bash
run: |
unzip miktexsetup-5.1-x64.zip
if: matrix.config.os == 'windows-latest'
Step 3:
- name: Download MikTex packages (Windows)
shell: bash
run: |
./miktexsetup_standalone --verbose \
--local-package-repository=C:/miktex-repository \
--remote-package-repository="https://ctan.math.illinois.edu/systems/win32/miktex/tm/packages/" \
--package-set=essential \
download
if: matrix.config.os == 'windows-latest'
Step 4 (the failing step):
- name: Install MikTex packages (Windows)
shell: bash
run: |
./miktexsetup_standalone --local-package-repository=C:/miktex-repository \
--package-set=essential \
--shared \
install
if: matrix.config.os == 'windows-latest'
Step 5:
- name: Setting MikTex paths (Windows)
shell: bash
run: |
echo "C:/Program Files/MiKTeX/miktex/bin/x64/" >> $GITHUB_PATH
export PATH="/c/Program Files/MiKTeX/miktex/bin/x64/:$PATH"
echo "Configuring MiKTeX to install missing packages on the fly"
initexmf --admin --verbose --set-config-value='[MPM]AutoInstall=1'
if: matrix.config.os == 'windows-latest'
Any ideas how to solve this problem / what can be the problem?
Based on discussions in https://github.com/MiKTeX/miktex/discussions/1204 and https://github.com/MiKTeX/miktex/issues/1213 the solution is to replace the MiKTeX version's zip file
from:
miktexsetup-5.1-x64.zip
to:
miktexsetup-5.2.0+b8f430f-x64.zip
I'm trying to pass a JSON structure required to register a new release in GitLab, but I'm not sure how I should escape the double quotes. Here's a release job section from my gitlab-ci.yml:
release:
stage: release
tags:
- windows
rules:
- if: $CI_COMMIT_TAG
variables:
ASSET_LINK_DETAILS: "{\"name\":\"${PACKAGE_NAME}.zip\",\"url\":\"${PACKAGE_REGISTRY_URL}/${PACKAGE_NAME}.zip\"}"
script:
- 'Write-Host "Creating release..."'
- 'Start-Process -FilePath "release-cli" -ArgumentList "create --name `"Release $CI_COMMIT_TAG`" --tag-name `"$CI_COMMIT_TAG`" --asset-link ${env:ASSET_LINK_DETAILS}" -NoNewWindow -Wait'
- 'Write-Host "Finished creating release..."'
Running this job returns an error from the release-cli:
Incorrect Usage: flag provided but not defined: -asset-link
What is the correct way to pass this JSON into the command in PowerShell?
I found the answer in the GitLab release documentation, there's a complete example there. PowerShell can be a PITA...
https://docs.gitlab.com/ee/user/project/releases/release_fields.html#use-a-generic-package-for-attaching-binaries
Here's an example:
- $env:asset = "{`"name`":`"$env:PACKAGE_NAME.zip`",`"url`":`"$env:PACKAGE_REGISTRY_URL/$env:PACKAGE_NAME.zip`"}"
- $env:assetjson = $env:asset | ConvertTo-Json
- Start-Process -FilePath "C:\GitLab\Release-CLI\bin\release-cli" -ArgumentList "create --name `"$CI_COMMIT_TAG`" --description `"Release $CI_COMMIT_TAG`" --tag-name `"$CI_COMMIT_TAG`" --ref `"$CI_COMMIT_TAG`" --assets-link=$env:assetjson" -NoNewWindow -Wait
when running terratest locally with an assertion it works as expected. But when trying to run it via a github action i get the error below (removing the assertion has terratest running as expected):
TestTerraform 2022-07-27T08:34:49Z logger.go:66: ::set-output name=exitcode::0
output.go:19:
Error Trace: output.go:19
terraform_test.go:24
Error: Received unexpected error:
invalid character 'c' looking for beginning of value
Test: TestTerraform
The terratest file looks like:
package test
import (
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
"testing"
)
func TestTerraform(t *testing.T) {
iam_arn_expected := "arn:aws:iam::xxx:role/terratest_iam"
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
TerraformDir: "../examples/simple",
Vars: map[string]interface{}{
"iam_name": "terratest_iam",
"region": "eu-west-2",
},
})
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
iam_arn := terraform.Output(t, terraformOptions, "iam_arn")
assert.Equal(t, iam_arn_expected, iam_arn)
}
the github action looks like:
jobs:
terratest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-go#v3.2.1
- name: Install tfenv
run: |
git clone https://github.com/tfutils/tfenv.git ~/.tfenv
echo "$HOME/.tfenv/bin" >> $GITHUB_PATH
- name: Install Terraform
working-directory: .
run: |
pwd
tfenv install
terraform --version
- name: Download Go Modules
working-directory: test
run: go mod download
- name: Run Terratest
working-directory: test
run: go test -v
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PLAYGROUND_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PLAYGROUND_KEY }}
The solution is to use the HashiCorp setup-terraform action with the Terraform wrapper turned off in place of your "Install Terraform" step.
- name: Setup Terraform
uses: hashicorp/setup-terraform#v2
with:
terraform_version: 1.3.6
terraform_wrapper: false
I'm setting up github actions to test my xcode app (kotlin multiplatform) and for some reason my build is not successful until pod installing a second time after attempting to build.
So I pod install -> build -> build fails -> pod install again -> build -> build succeeds.
Steps to reproduce this locally:
Checkout the repo
arch -x86_64 pod install
xcodebuild ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO -workspace myworkspace.xcworkspace -scheme
myScheme -configuration Release -destination 'platform=iOS Simulator,name=iPhone 12,OS=15.4'
The build fails on this step trying to import the common kotlin library:
import common
^
** BUILD FAILED **
and then if I run these steps again
arch -x86_64 pod install
xcodebuild ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO -workspace myworkspace.xcworkspace -scheme myScheme -configuration Release -destination 'platform=iOS Simulator,name=iPhone 12,OS=15.4'
the build is successful
/usr/bin/codesign --force --sign - --entitlements /Users/me/Library/Developer/Xcode/DerivedData/myApp-esecylpzfadofbsakhxtkqqgzuk/Build/Intermediates.noindex/myApp.build/Release-iphonesimulator/myApp.build/myApp.app.xcent --timestamp\=none --generate-entitlement-der /Users/me/Library/Developer/Xcode/DerivedData/myApp-esecylpzfadofbsakhxtkqqgzuk/Build/Products/Release-iphonesimulator/myApp.app
** BUILD SUCCEEDED **
Here is my podfile:
platform :ios, '15.2'
use_frameworks!
inhibit_all_warnings!
def shared_pods
pod 'common', :path => '../common'
pod 'GoogleSignIn'
end
target 'myApp' do
shared_pods
end
target 'myApp_Tests' do
shared_pods
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
end
and here's my BuildTests.yaml file for github actions
name: ios-unit-tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
run_tests:
runs-on: macos-latest
strategy:
matrix:
include:
- ios: "15.2"
name: test iOS (${{ matrix.ios }})
steps:
- uses: actions/setup-java#v2
with:
distribution: 'temurin'
java-version: '11'
- name: Checkout repository
uses: actions/checkout#v3
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Install M1 Pod
run: sudo arch -x86_64 gem install ffi;
- name: Pod Install
run: cd myApp; which pod; rm myApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved; arch -x86_64 pod install
- name: Build
run: xcodebuild ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO -workspace myApp/myApp.xcworkspace -scheme myApp -configuration Release -destination 'platform=iOS Simulator,name=iPhone 12,OS=${{ matrix.ios }}'
- name: Run unit tests
run: xcodebuild test -workspace myApp/myApp.xcworkspace -scheme myApp -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12,OS=${{ matrix.ios }}'
UPDATE:
Resolution was to delete .gitignore and build the project and see which files changed. Turned out there were some build files commented out that should have been committed
I have a hard time to publish a package to AWS CodeArtifact. Problem is the authentification.
First I tried to execute the login via the aws cli but due to the lack of the .pypirc file containing the repository settings that didn't work out. Now I tried to store the token and feed it into the --repository-url but in both cases I end up that the process wants a username anyway.
Stacktrace:
File "/opt/hostedtoolcache/Python/3.9.1/x64/bin/twine", line 8, in <module>
sys.exit(main())
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/__main__.py", line 28, in main
result = cli.dispatch(sys.argv[1:])
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/cli.py", line 82, in dispatch
return main(args.args)
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/commands/upload.py", line 154, in main
return upload(upload_settings, parsed_args.dists)
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/commands/upload.py", line 91, in upload
repository = upload_settings.create_repository()
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/settings.py", line 345, in create_repository
self.username,
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/settings.py", line 146, in username
return cast(Optional[str], self.auth.username)
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/auth.py", line 35, in username
return utils.get_userpass_value(
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/utils.py", line 241, in get_userpass_value
return prompt_strategy()
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/auth.py", line 81, in username_from_keyring_or_prompt
return self.prompt("username", input)
File "/opt/hostedtoolcache/Python/3.9.1/x64/lib/python3.9/site-packages/twine/auth.py", line 92, in prompt
return how(f"Enter your {what}: ")
EOFError: EOF when reading a line
Enter your username:
Error: Process completed with exit code 1.
Partial github-action.yml:
steps:
- uses: actions/checkout#v2
- name: Set up Python
uses: actions/setup-python#v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials#v1
with:
aws-access-key-id: ${{ secrets.AWS_CA_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_CA_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Build and publish
run: |
token=$(aws codeartifact get-authorization-token --domain foobar --domain-owner 123456678901 --query authorizationToken --output text)
python setup.py sdist bdist_wheel
twine upload --repository-url https://aws:$token#foobar-123456678901.d.codeartifact.eu-central-1.amazonaws.com/pypi/my-repo/simple dist/*
You need to pass to twine the correct authentication values, try with the following:
twine upload --repository-url https://foobar-123456678901.d.codeartifact.eu-central-1.amazonaws.com/pypi/my-repo/simple --username aws --password $token dist/*
see: https://twine.readthedocs.io/en/latest/#commands
The AWS CLI lets you configure credentials for twine so you don't have to pass them explicitly.
- name: Build and publish
run: |
aws codeartifact login --tool twine --domain foobar --repository my-repo
python setup.py sdist bdist_wheel
twine upload --repository codeartifact dist/*
Links:
https://docs.aws.amazon.com/codeartifact/latest/ug/python-configure.html
https://docs.aws.amazon.com/codeartifact/latest/ug/python-run-twine.html