seandepagnier / weatherfax_pi

weather fax plugin for opencpn
GNU General Public License v3.0
20 stars 27 forks source link

Use of appveyor 'auth_token' to push a new github release #134

Closed rgleason closed 5 years ago

rgleason commented 5 years ago

I've been getting this result:

Collecting artifacts...
Found artifact 'build\weatherfax_pi-1.9.002-ov42-win32.exe' matching 'build\weatherfax_pi*.exe' path
Uploading artifacts...
[1/1] build\weatherfax_pi-1.9.002-ov42-win32.exe (721,850 bytes)...100%
Deploying using GitHub provider
Creating "weatherfax_pi-'v1.9.2-ov42'-win32" release for repository "rgleason/weatherfax_pi" tag "v1.9.2-ov42" commit "c393a31c6d2b6c673aa4d2fd97aa89583821ae18".
..Error creating GitHub release: 
Error reading repository 'rgleason/weatherfax_pi' releases: 401 - Unauthorized

It is obvious now that authorization keys are not set up correctly. Pushing to remote Git repository from a build

Also useful Publishing to github releases - Provider settings

GitHub authentication token (auth_token) - OAuth token used for authentication against GitHub API. You can generate Personal API access token at https://github.com/settings/tokens. Minimal token scope is repo or public_repo to release on private or public repositories respectively. Be sure to encrypt your token using “Encrypt configuration data” page in AppVeyor (Settings → Encrypt YAML). - I thought I had done this, but I misunderstood something.

Under my github account user > settings > developer (at the bottom) there are 3 selections

Some notes from a user:

In order for appveyor to upload to Github releases you have to generate a token on github and give it to appveyor. Instructions here "GitHub authentication token" - https://www.appveyor.com/docs/deployment/github cache:

  • C:\Users\appveyor.m2

Bottom of the users appveyor, similar to mine.

deploy:
  - provider: GitHub
    auth_token:
      secure: Hq5VDnfPj9yDRim502Eyhn7rFSgjfo3TiRs2xM+qP/wm/Wav6q/XeVNIGEEdXbtN
    artifact: mavgclinstaller
    draft: false
    prerelease: false
    on:
appveyor_repo_tag: true 
rgleason commented 5 years ago

We, after horsing around with a new security key, reapplying the security settings in git, moving and simplifying parts of appveyor.yml there is finally a file from Artifacts that lands in the Git Release area as a release! I was about to quit.

Uploading "weatherfax_pi-1.9.3-ov42-win32.exe" to release assets...OK
Build success

I have commented out the tag: $(appveyor_repo_tag_name) and (appveyor_repo_tag):true which create the version number and deploy on tag push only.

This is the appveyor.yml file used for weatherfax_pi at this point, will push every new file up to Release. The security token used is encrypted by yaml and can only be used on my repository. appveyor.yml.txt

Next step is to get the version number correct and deploy on tag push only working. However those worked before but the file did not get pushed due to an authentication error. I'd like to end up with green checks for both conditions (tag pushed to release or not)

This painful exercise has also forced me to learn how to use git rebase -i HEAD~ some number of lines which is good.

The appveyor forum discussion has more detailed notes at the bottom of my post. https://help.appveyor.com/discussions/problems/23134-push-built-file-to-opensource-public-github-release

During this process I had to consider this to, and worked around it with a new branch. Git branch --delete and Git Squash -Effect on Appveyor

rgleason commented 5 years ago

Uncommented these lines in appveyor.yml:

tag: $(APPVEYOR_REPO_TAG_NAME) # insert version name APPVEYOR_REPO_TAG: true # deploy on tag push only

Then pushed appveyor.yml to remote. Then pushed a new tag to remote with:

git tag v1.9.3-ov42-test git push origin v1.9.3-ov42-test

upon which a new Release & Tag "v1.9.3-ov42-test" gets created which now contains the results of the Appveyor build under "Assets" find "weatherfax_pi-1.9.3-ov42-win32.exe". See https://github.com/rgleason/weatherfax_pi/releases/tag/v1.9.3-ov42-test

The Appveyor Console shows: https://ci.appveyor.com/project/rgleason/weatherfax-pi

Collecting artifacts...
Found artifact 'build\weatherfax_pi-1.9.3-ov42-win32.exe' matching 'build\*.exe' path
Uploading artifacts...
[1/1] build\weatherfax_pi-1.9.3-ov42-win32.exe (721,873 bytes)...100%
Deploying using GitHub provider
Creating "v1.9.3-ov42-test" release for repository "rgleason/weatherfax_pi" tag "v1.9.3-ov42-test" commit "05b6418e674b7d722424146c8efe2745a88b635b"...OK
Uploading "weatherfax_pi-1.9.3-ov42-win32.exe" to release assets...OK
Build success

This is the appveyor.yml that is used used currently (it may change a little) appveyor.yml.txt

For more information about setting the auth_token security please read the notes made in appveyor discussions: *Push built Artifact .exe to Github "Release" (opensource, public repos, dev account)** See Post 13 Posted by fcgleason on Apr 23, 2019 @ 09:31 PM Also see Git branch --delete and Git Squash -Effect on Appveyor might be useful.

rgleason commented 5 years ago

I am going to make a another new branch "deploy-win3" and clean up with git rebase -i HEAD~xxx Then make a PR to Sean. To get this working Sean will have to add his own encrypted auth_token.

This ov42 appveyor file will still work to create Artifacts, even if the auth_token is not changed.